Dears, In my external method I can get mime_type = file.headers.headers[1].split()[1] and then my code proceed based on which mime type was identified for the file uploaded. What happens now is that a user uploading a tgz file from a Windows platform and then my code did not identify it as a application/x-gzip-compressed or similar (it gets application/octet-stream). As far as I understood from this case, such mime type info is passed by user's system (where Windows usually is not aware of tar.gz, tgz etc format) rather than being set by zope server. So since I was not aware of that, my question is: does anyone know a better and reliable way of identifying a file mime type (or a file format) independent from which platform/browser it is submitted? I realise I can use a conditional for checking extension file name in addition to mime type detection. But I would go for that only if I cannot find anything fairer. Many thanks in advance. Alan -- Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate Department of Biochemistry, University of Cambridge. 80 Tennis Court Road, Cambridge CB2 1GA, UK.
--On 24. Mai 2007 11:31:17 +0100 Alan <alanwilter@gmail.com> wrote:
Dears,
In my external method I can get mime_type = file.headers.headers[1].split()[1] and then my code proceed based on which mime type was identified for the file uploaded.
What happens now is that a user uploading a tgz file from a Windows platform and then my code did not identify it as a application/x-gzip-compressed or similar (it gets application/octet-stream).
As far as I understood from this case, such mime type info is passed by user's system (where Windows usually is not aware of tar.gz, tgz etc format) rather than being set by zope server.
AFAIK..all Zope types derived from OFS.File or OFS.Image are using OFS.contenttypes.guess_content_types()...if the 'content-type' header isn't available. Otherwise Zope will use it. -aj
participants (2)
-
Alan -
Andreas Jung