We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

passing header with the url

Thread ID:

Created:

Updated:

Platform:

Replies:

146521 May 8,2018 10:01 AM UTC Aug 7,2019 05:35 AM UTC Angular - EJ 2 5
loading
Tags: PDF Viewer
Manu
Asked On May 8, 2018 10:01 AM UTC

Hello 

For the uploader control, is there a way to send the header with the url

For example : In angular http
this.http.post(url, body, header)




Karthik Ravichandran [Syncfusion]
Replied On May 9, 2018 12:11 PM UTC

Hi Manu, 

Thanks for contacting Syncfusion support.  

We have checked your query. You can achieve your requirement (“Add headers in the save and remove url’s”) by using uploading and removing events of uploader. Please refer the below code block. 

<ejs-uploader #defaultupload (uploading)="onuploading($event)" (removing)="onremove($event)" [asyncSettings]='path'></ejs-uploader> 
 
 
// To add the header in save Url 
public onuploading(args: any) {  
   args.currentRequest.setRequestHeader('Authorization', ‘username’);  
} 
 
// To add header in remove Url 
public onremove(args:any) {  
  args.currentRequest.setRequestHeader('Authorization', ‘username’);  
} 
 
 
Make sure that your custom header has been added in web.config file of your service. Please refer below code block. 
[web.config] 

<customHeaders> 
<add name="Access-Control-Allow-Headers" value="accept, maxdataserviceversion, origin, x-requested-with, dataserviceversion,content-type, Authorization" />    
… 
</customHeaders> 
 
Note: The feature “adding custom header in upload HTTP request” implemented and available from our 16.1.37 release.  

Please let us know if you need further assistance on this. 

Regards, 
Karthik R 


Matthew Morgan
Replied On December 27, 2018 06:57 PM UTC

This doesn't work with chunked file uploading. The uploading event is only fired on the initial chunk and subsequent chunks provide no opportunity to add a header. In my case, this is fatal because I need to add a bearer token for OIDC.

Prince Oliver [Syncfusion]
Replied On January 3, 2019 08:59 AM UTC

Hi Manu, 

Thank you for your update. 

You can also achieve same behavior for chunk upload. Recently we have introduced ‘chunkUploading’ event starting from the release version 16.4.40-beta. You can upgrade your packages through npmjs and try to pass header in the chunkUploading event arguments. Kindly refer to the following code snippet 
 
<ejs-uploader #chunkUpload [maxFileSize]=104857600 [autoUpload]=false (chunkUploading)="onChunkUploading($event)" (removing)="onRemove($event)" [asyncSettings]='path'></ejs-uploader>  
  
  
// To add the header in save Url on every chunk upload 
public onChunkUploading (argsany) {   
   args.currentRequest.setRequestHeader('Authorization'‘username’); 
}  
  
// To add header in remove Url  
public onRemove(args:any) {   
  args.currentRequest.setRequestHeader('Authorization', ‘username’); 
}  
  

The chunkUploading event will trigger for uploading each chunk. Kindly refer to the following API reference: https://ej2.syncfusion.com/documentation/api/uploader/#chunkuploading  

Please let us know if you need any further assistance on this. 

Regards, 
Prince 


Ervin van der Merwe
Replied On August 6, 2019 08:00 AM UTC

I have the same requirement but from the angular PDF Viewer: https://www.syncfusion.com/forums/146490/how-to-pass-headers-with-pdf-viewer

Akshaya Arivoli [Syncfusion]
Replied On August 7, 2019 05:35 AM UTC

Hi Ervin, 

We have provided the details for “How to Pass Headers With PDF Viewer” in the forum https://www.syncfusion.com/forums/146490/how-to-pass-headers-with-pdf-viewer . Please check that for further updates and revert us if any concerns. 

Regards, 
Akshaya 



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon