How does one upload a file with the SfUploader with custom metadata.
The only thing that seems to come across is the filename.
I chatted with support, and found some articles, but none of them worked for .Net 6 and Blazor WASM.
I need to set parameters at the client, and extract them at the server.
I've read the above, it doesn't work. It's not Blazor WASM, and it's not .Net 6
HI Kevon,
We have prepared the sample with passed the additional parameter by using the fileselect event.
Find the code example here:
[sample.razor] <SfUploader ID="UploadFiles"> <UploaderEvents FileSelected="onFileSelect"></UploaderEvents> <UploaderAsyncSettings SaveUrl="api/SampleData/Save"> </UploaderAsyncSettings> </SfUploader> @code { private void onFileSelect(SelectedEventArgs args) { var accessToken = "Basic test123"; args.CurrentRequest = new List<object> { new { Authorization = accessToken } }; } } [samplecontroller.cs] [HttpPost("[action]")] public async void Save(IList<IFormFile> UploadFiles) { //to get authorization Header to handle save file on server side var authorizationHeader = Request.Headers["Authorization"]; try {
|
Find the screenshot for the output:
|
Find the sample in the attachment:
Regards,
Sureshkumar P
Thank you for the reply. This example is a little simplistic. I have tried to extend this to adding an object to the header, but it seems this is not possible?
You can see this at the client
The Data is being inserted properly
But at the server, it is inaccessible.
It seems a standard use case to upload files with complex data associated. Can you suggest a way to accomplish this?
I figured it out...
The header is string based, so the data must be in a string format...
On the client:
On the server:
Hi Kevon,
Thanks for your update.
Regards,
Sureshkumar P