I am using Spring 3 to upload a file. I would like to know how best to verify that the file is of a specific type, in particular the csv file. I am sure that checking the extension is useless, and I'm currently checking the type of contents of the uploaded file. I just guarantee that it is of type "text / csv". And just for clarification, this is a file downloaded by the client, that is, I do not control its origin.
I am curious how Spring / browser determines the type of content? Is this the best / safe way to determine which file has been downloaded? Can I ever be 100% sure?
UPDATE: Again, I am not interested in how to determine the type of file content, but how the type of content is determined. How does Spring / browser know that the content type is "text / csv" based on the downloaded file?
sauce source
share