With Chunking enabled, I am seeing a different Content-Type reported on the client:
Than what I see on the server:
Is there a setting to have these report the same?
Hi Mike,
We have validated the reported issue, but we get the same content type compared with server and client file upload.
Find the screenshot of chunk upload:
|
|
Regards,
Sureshkumar P
Thank you for your time and investigation Sureshkumar. Can you verify that chunking is enabled? I see that the length is only roughly 165KB. Note that I specified chunking was to be enabled. By this I meant that it is enabled and more than one chunk is encountered. Note further that in my case my chunks are set to 4MB as that is the max size of Azure Append Blob append opera
When chunk upload is enabled basically, we would just put the blob content in the request body and use application/octet-stream as the content type. Because in chunk upload the file is converted as blob by blob to upload based on file size and chunk size. Which is the reason the chunk upload returns the application/octet-stream as the content type
Also, share your exact use case scenario to change the content type from application/octet-stream into application/x-zip-compressed. These details will help us to provide an exact solution as earlier as possible.
Hi @Sureshkumar, I would recommend a EnableOriginalContentType property that sends the originally reported content type. This would default to false to keep existing behavior. If the user selects true, then the file content type is sent with the IFormFile rather than the blob content type.
Thank you for any further consideration and/or discussion.
Hi Mike,
On further validation , we found that its native file upload behavior
in case of chunk uploading , Hence it couldn’t be changed/modified . So as
mentioned earlier while chunk uploading the file get uploaded blob by blob based
on the fields such as file size and chunk size
, And it will return as application/octet-stream
as the content type at server end.
Thanks,
Deepak R.
Thank you for the update Deepak. Any suggestions on how I can persist/store the content-type for the provided files? I need to store this in my database as it describes the type of file it is. Currently, I am sending a custom header over but that only works when using a single file. This is OK for the short term but I anticipate using/supporting multiple files in the future.
Hi Mike,
Thanks for your update.
Yes we can sent multiple number of file types from client to
server using CustomFormData and Headers
as like below mentioned code .
[Index.razor]
|
<SfUploader ID="UploadFiles" AutoUpload="true"> <UploaderAsyncSettings SaveUrl="api/SampleData/Save" ChunkSize="500000"></UploaderAsyncSettings> <UploaderEvents FileSelected="@Selected" ></UploaderEvents> </SfUploader>
@code{
void Selected(SelectedEventArgs args) { var fileList = args.FilesData; string[] fileTypes = new string[fileList.Count()]; for(var i = 0; i<fileList.Count();i++) { fileTypes[i] = fileList[i].Type; } args.CustomFormData = new List<object> { new { FileList = fileTypes } }; }
} |
[SampleDataController]
|
[HttpPost("[action]")] public async Task Save(IList<IFormFile> UploadFiles) {
var ContainerName = Response.HttpContext.Request.Form["FileList"]; }
|
[Snapshot]
Also you can refer the below attached sample for reference.
Thanks,
Deepak R.
Amazing. Thank you very much for that Deepak, and for your patience in answering my questions as I learn your awesome API. :)
Hi Mike ,
We are glad that your requirement has fulfilled in your end . We are always
happy to assist you.
Thanks,
Deepak R.