New Product LaunchBoldDesk: Help desk ticketing software.
Try it for free.
<ejs-filemanager id='overview' (beforeSend)="beforeSend($event)" [ajaxSettings]='ajaxSettings' [view]='view'>
</ejs-filemanager>
//File Manager's beforeSend event
beforeSend(args: any){
//Ajax beforeSend event
args.ajaxSettings.beforeSend = function (args) {
//Setting authorization header
args.httpRequest.setRequestHeader("Authorization", "Bearer-1233")
}
} |
<ejs-filemanager #filemanager id='overview' [ajaxSettings]='ajaxSettings' (beforeSend)="beforeSend($event)" [view]='view' (toolbarClick)='toolbarClick($event)' (menuClick)='menuClick($event)'>
</ejs-filemanager>
beforeSend(args: any) {
//Ajax beforeSend event
args.ajaxSettings.beforeSend = function (args) {
//Setting authorization header
args.httpRequest.setRequestHeader("Authorization", "Bearer-1233")
}
}
|
[Controller]
Route("Download")]
public IActionResult Download(string downloadInput)
{
// To expose content disposition header at client side.
Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition");
FileManagerDirectoryContent args = JsonConvert.DeserializeObject<FileManagerDirectoryContent>(downloadInput);
return operation.Download(args.Path, args.Names);
}
|
[TS]
public toolbarClick(args: any): void {
if (args.item.id === this.filemanagerObj.element.id + '_tb_download') {
//Preventing default download using toolbar
args.cancel = true;
this.customDownload([]);
}
}
public menuClick(args: any) {
if (args.item.id === this.filemanagerObj.element.id + '_cm_download') {
//Preventing default download using context menu
args.cancel = true;
this.customDownload(args.fileDetails);
}
}
public customDownload(files) {
var flag = (this.filemanagerObj.selectedItems.length !== 0);
if ((files.length !== 0) || flag) {
//Creating data for the controller
.....
.....
let fdata: FormData = new FormData();
fdata.append('downloadInput', JSON.stringify(data));
//Custom Header Added to XHR
xhr.setRequestHeader('Custom-Header', 'Syncfusion');
xhr.send(fdata);
}
}
|
beforeSend(args: any) {
var data = JSON.parse(args.ajaxSettings.data);
// Add custom parameter column
data["column"] = "value";
// Add custom parameter in ajax settings
args.ajaxSettings.data = JSON.stringify(data);
//Ajax beforeSend event
args.ajaxSettings.beforeSend = function (args) {
//Setting authorization header
args.httpRequest.setRequestHeader("Authorization", "Bearer-1233")
}
}
|
public class FileManagerDirectoryContent1
{
public string Action { get; set; }
public string Path { get; set; }
public FileManagerDirectoryContent TargetData { get; set; }
public AccessPermission Permission { get; set; }
public string column { get; set; }
} |
beforeSend(args: any) { var data = JSON.parse(args.ajaxSettings.data); // Add custom parameter column data["column"] = "value"; // Add custom parameter in ajax settings args.ajaxSettings.data = JSON.stringify(data); //Ajax beforeSend event args.ajaxSettings.beforeSend = function (args) { //Setting authorization header args.httpRequest.setRequestHeader("Authorization", "Bearer-1233") } } |
beforeSend(args: any) {
//Ajax beforeSend event
args.ajaxSettings.beforeSend = function (args) {
//Setting authorization header
// It is not a static token.
args.httpRequest.setRequestHeader("Authorization", "Bearer-1233")
}
}
|
var data = {
'action':
'path':
'names':
'data':
}; |
<ejs-filemanager
id="overview"
[ajaxSettings]="ajaxSettings"
(beforeImageLoad)="beforeImageLoad($event)"
[view]="view"
>
</ejs-filemanager>
beforeImageLoad(args) {
// Add custom parameter in image URL
args.imageUrl = args.imageUrl + "&custom_attribute=" + "Syncfusion";
} |
public class FileManagerDirectoryContent1
{
public string Name { get; set; }
public string custom_attribute { get; set; }
public string[] Names { get; set; }
}
[Route("GetImage")]
public IActionResult GetImage(FileManagerDirectoryContent1 args)
{
return this.operation.GetImage(args.Path, args.Id,false,null, null);
} |
Hi Luke Mitchell,Based on the current implementation of FileManager component, we have used form submit for download operations of FileManager component and not a ajax request. So, we can’t add the JWT token with this request. However, you can add the custom data to the download operations using beforeDownload event.Please, refer the below forum link for beforeDownload operations.However, we have used Query parameter for GetImage operations of FileManager component. Other than the two operations ( Download, GetImage), you can send the JWT token using beforeSend event of FileManager component.Please let us know, if you need any further assistance.Regards,Sowmiya.P