Hi Team,
is it possible to add Authorization Bearer Token to ajaxSettings?
Regards,
Yonz
Regards,
Prasanth Madhaiyan.
Hi Prasanth,
I've implemented the code from the provided link and confirmed that all functions operate as expected, with the exception of the delete button functionality after file upload. Please refer to the attached image for context.
... <div class="sample-container"> <ejs-filemanager id="overview" #filemanager [ajaxSettings]="ajaxSettings" (beforeSend)="onBeforeSend($event)" (beforeDownload)="onBeforeDownload($event)" (beforeImageLoad)="onBeforeImageLoad($event)" (created)="OnCreated()" > </ejs-filemanager> </div> |
... export class AppComponent { @ViewChild('filemanager') fileObject: FileManagerComponent; .. OnCreated() { var fmObj = this.fileObject; this.fileObject.uploadObj.removing = function (args) { if (args.event != null) { args.customFormData = [ { path: fmObj.path }, { size: args.filesData.size }, { action: 'remove' }, { data: null }, { filename: args.filesData.name }, ]; } if (fmObj.uploadObj.fileList.length == 1) { fmObj.uploadDialogObj.hide(); } }; } ... } ... |
Regards,
Prasanth Madhaiyan.
Hi Prasanth,
Even after implementing the code you provided, the delete function in the upload dialog is still not sending the authorization header to my web service. Furthermore, I've noticed that the delete action is incorrectly triggering the upload function on the web service instead of the intended file operation.
Regards,
Yonz
Regards,
Prasanth Madhaiyan.
Hi Prasanth,
Thank you for clarifying that triggering the "remove" action in the Upload dialog calls the Upload method.
My concern, however, is that the remove action does not seem to be passing the Authorization header to the server. This is preventing successful deletion of the uploaded files. Please see the code below for your reference.
... export class AppComponent { ... OnCreated() { var fmObj = this.fileObject; this.fileObject.uploadObj.removing = function (args) { if (args.event != null) { args.currentRequest.setRequestHeader('Authorization', 'User1'); args.customFormData = [ { path: fmObj.path }, { size: args.filesData.size }, { action: 'remove' }, { data: null }, { filename: args.filesData.name }, ]; } if (fmObj.uploadObj.fileList.length == 1) { fmObj.uploadDialogObj.hide(); } }; } } |
public class FileManagerController : Controller { ... // uploads the file(s) into a specified path [Route("Upload")] public IActionResult Upload(string path, long size, IList<IFormFile> uploadFiles, string action) { var header = HttpContext.Request.Headers["Authorization"]; ... } ... } |
Regards,
Prasanth Madhaiyan.
Hi Prasanth,
Thank you so much for your help with the code you provided. I've implemented it, and it's working perfectly.
Best regards,
Yonz
Hi Yonz,
Regards,
Prasanth Madhaiyan.