Hi,

I am using "Upload" Widget and trying to upload a  ".csv" file. 

Ideally it should return file type as "text/csv", but it's returning "application/vnd.ms-excel" .

In the attached screenshot, file uploaded was "Grant.Grant.csv" but the widget is returning incorrect "Type"

Any help would be appreciated.


Thanks

Solution

Hi Angel,

The content type is generally set by the browser during file upload, so it can depend on the browser and the configuration of the machine on which the browser is running.

"application/vnd.ms-excel" is commonly used for CSV files as well as "text/csv".  If you are using the content type, you should support this for CSV files.  Note it is also used for .xls, .xlt and .xla files according to this page https://docs.microsoft.com/en-us/archive/blogs/vsofficedeveloper/office-2007-file-format-mime-types-for-http-content-streaming-2

Often though, the file extension can be a more reliable way to determine the format of the file.

Here is a stack overflow post about how the browser sets the content type.

https://stackoverflow.com/questions/1201945/how-is-mime-type-of-an-uploaded-file-determined-by-browser

I hope this helps.

Kind regards,

Stuart

Solution

Hi Angel,

Could you share more about what you're trying to achieve? 

Like Stuart said, MIME types can have a lot of variation, and if you decide to use them for validation you'll need to be prepared for a lot of different values for a single file extension.

Afonso Carvalho wrote:

Hi Angel,

Could you share more about what you're trying to achieve? 

Like Stuart said, MIME types can have a lot of variation, and if you decide to use them for validation you'll need to be prepared for a lot of different values for a single file extension.

Hi Afonso,

Actually I am trying to give the ability to user to upload a ".csv" file and download it whenever required.


Why not just check the file extension? It would be less prone to errors than trying to go over all possible MIME types for CSV, and considerably easier to implement.

Hi Angel,


in my experience while uploading with IOS the mime type will be text/csv.
In ither cases we are using application/*excel....