How to call cutom method on File upload component SaveUrl method with same parameter.

Right now I am using file-upload component of blazor for uploading my file.

The main thing I am using the below chuck file uploading approch in file upload becasue my file size is high.

<SfUploader ID="UploadFiles">
    <UploaderAsyncSettings SaveUrl="api/SampleData/Save" RemoveUrl="api/SampleData/Remove" ChunkSize="500000"></UploaderAsyncSettings>
</SfUploader>


So, My main concern is that on SaveUrl can we able to use our own method with same signature ?

Suppose, right now On saveUrl we are using Save method, So is there any example or way that how can we use same method signture using diffrent name or
how can we call our own custom method with same method parameter on  SaveUrl?

example :-

HttpPost("[action]")]
    public void Save(IList<IFormFile> chunkFile, IList<IFormFile> UploadFiles)
    {
}
HttpPost("[action]")]
    public void Custom(IList<IFormFile> chunkFile, IList<IFormFile> UploadFiles)
    {
}
So is there any way possiable I can call Cutsom method on SaveUrl="api/SampleData/Custom" ?

3 Replies 1 reply marked as answer

JM Jeyanth Muthu Pratheeban Sankara Subramanian Syncfusion Team August 27, 2020 01:28 PM UTC

Hi Karan,

Greetings from Syncfusion support.

We would like to know you that you can customize the Save method to save a file and when you are doing, we suggest you to ensure that the save method name in the backend and in the SaveURL should be the same. We have made sample for your reference. Please find the sample in the below link. In that sample, we have changed save method name as CustomSave.


Sample Link: https://www.syncfusion.com/downloads/support/forum/157310/ze/Uploader1272691911 


 
<SfUploader ID="UploadFiles"> 
    <UploaderAsyncSettings SaveUrl="api/SampleData/CustomSave"> 
    </UploaderAsyncSettings> 
</SfUploader> 


Screenshot:


 
 

Regards, 
Jeyanth.

 



KA Karan August 28, 2020 02:42 PM UTC


We need to call method in the same page 
Razor page
<SfUploader ID="UploadFiles">     <UploaderAsyncSettings SaveUrl="SaveFile" RemoveUrl="api/SampleData/Remove" ChunkSize="500000"></UploaderAsyncSettings> </SfUploader>
public void SaveFile(IList<IFormFile> chunkFile, IList<IFormFile> UploadFiles)  {    } 
Here is the situation we have function which accept the file and upload the file to desired location and give the success call bakx and progress callback. So we need to call that function directly from saveurl. We dont want to call the api controller to upload the file. We want to upload chunk of the file to somewhere else not in current server.
The other server do not have api kind feature.We have to get the session to upload the file. So all of the process we need to carry out from same function to be able to upload the file.


JM Jeyanth Muthu Pratheeban Sankara Subramanian Syncfusion Team September 1, 2020 04:34 PM UTC

Hi Karan, 

Thanks for your explanation.

We would like to know you that ValueChange event will be triggered when file is uploaded where you can get the filestream of the uploaded file. You can make use of the filestream for that custom method. Please find the sample below.

Sample Link       : https://www.syncfusion.com/downloads/support/forum/157310/ze/Uploader-305356950 

Regards, 
Jeyanth. 


Marked as answer
Loader.
Up arrow icon