Reported Client Content-Type Differs from Reported Server Content-Type

With Chunking enabled, I am seeing a different Content-Type reported on the client:

Lj4cJAw[1].png

Than what I see on the server:

N6k0d5I[1].png

Is there a setting to have these report the same?


9 Replies 1 reply marked as answer

SP Sureshkumar P Syncfusion Team April 7, 2022 11:23 AM UTC

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



MI Mike-E April 7, 2022 02:02 PM UTC

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



SP Sureshkumar P Syncfusion Team April 8, 2022 11:09 AM UTC

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.



MI Mike-E April 9, 2022 09:28 AM UTC

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.



DR Deepak Ramakrishnan Syncfusion Team April 12, 2022 06:02 PM UTC

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.



MI Mike-E April 12, 2022 09:10 PM UTC

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.



DR Deepak Ramakrishnan Syncfusion Team April 13, 2022 04:27 PM UTC

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.


Attachment: BlazorApp1_f837e0ee.zip

Marked as answer

MI Mike-E April 13, 2022 07:25 PM UTC

Amazing.  Thank you very much for that Deepak, and for your patience in answering my questions as I learn your awesome API. :)



DR Deepak Ramakrishnan Syncfusion Team April 15, 2022 05:49 AM UTC

Hi Mike ,

We are glad that your requirement has fulfilled in your end . We are always happy to assist you.


Thanks,

Deepak R.


Loader.
Up arrow icon