Hi,

VP wrote:
> Does anybody have this problem?
I would say that's not a problem but something you have to expect.

> I am trying to upload a CSV file. Here is a small part of my script:
> ...
> file = request.files['my_file']
> if file.content_type == 'text/csv':
> ...
> 
> In Safari it works, but in Firefox it shows all the time 'text/plain'
> content type.
The content type of an uploaded file is determined by the browser that
sends the file (if the browser decides to specify a content type which
it does not have to and often does not).  So in that situation the
browser (Firefox) decides to use the text/plain content type for the
uploaded file.  In fact, no browser currently gets the mimetype stuff
correct.  While Safari appears to have a wider range of mimetypes for
uploads, it sends totally broken accept headers.

Rule of thumb: never rely on mimetypes.  If you do want to provide
support for mimetypes anywhere in the application, provide a fallback
that works without mimetypes (eg: based on the file extension).

> I put in /etc/mime.types file this line:
That won't help, that file is only used for mimetype guessing by
extension and that one is (by werkzeug) only used for the shared data
middleware and will most likely no longer do that due to problems of
portability.  So changing that file is not really reliable.


Regards,
Armin

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pocoo-libs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pocoo-libs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to