Change asyncSettings AJAX POST request to PUT request

The default ajax request used by syncfusion Uploader is POST request, is there a way to change it to PUT request?
Or Can we use our own custom request on upload?


3 Replies

SP Sureshkumar P Syncfusion Team January 20, 2022 01:11 PM UTC

Hi Hamid,  
 
We can give the custom service link to asyncSettings as mentioned below,  
 
  public path: Object = {  
        saveUrl: 'https://localhost:44379/Home/Save',  
        removeUrl: 'https://localhost:44379/Home/Remove'  
    };  
 
 
 
Regards,  
Sureshkumar P 
 



HA Hamid Akhtar January 20, 2022 02:05 PM UTC

Yes I have read it in the documentation but I want to change the request as the default request  is "POST". I want to change it to "PUT""



PO Prince Oliver Syncfusion Team January 21, 2022 02:35 PM UTC

Hi Hamid, 

Currently our upload component does not provide built-in option to change the request type from POST to PUT. But you can achieve your requirement through custom PUT request in the BeforeUpload event in the uploader. 
[HTML] 
<ejs-uploader #defaultupload id='UploadFiles' [asyncSettings]='path' [dropArea]='dropElement' (removing)='onFileRemove($event)' (beforeUpload)='onupload($event)' ></ejs-uploader> 


Before upload event triggers before the upload process begins. You can cancel the POST request using args.cancel as true and make your custom PUT request call to server  

[TS] 
    Public onupload(args): void { 
        args.cancel = true; // Cancel POST request   
        var files = this.uploadObj.files; // Get selected Files   
        // Make your custom PUT request here  
        $.ajax({ 
            url: "/upload", 
            type: "PUT", 
            data: { Files : files}, 
            processData : false, 
            error: function(jqXHR, textStatus, errorThrown) { 
                alert("Error: " + errorThrown); 
            }, 
            success: function(responseData){ 
               alert("success"); 
            } 
        });  
    } 


Regards, 
Prince 


Loader.
Up arrow icon