Re: [Zope-dev] [Zope] Header information on file upload

2003-02-01 Thread Florent Guillaume
Martin Gebert  <[EMAIL PROTECTED]> wrote:
> In my HowTo about dealing with BLOBs 
>  I use a rather 
> unelegant but working method to get the content type of an uploaded 
> file. Stefan Tjarks has now drawn my attention to the Header attributes 
> of the uploaded form data, namely the "Content-Type" attribute which 
> seems to reveal the MIME type (photo.headers['Content-Type'] for the 
> given exsample).
> My sorrow is now that this information isn't 100 % reliable, 'cause the 
> Zope core (esp. the Image and File classes) doesn't seem to use this 
> possibility either, but implements it's own methods which I use in the 
> HowTo, too. The responsible class ZPublisher.HTTPRequest.FileUpload 
> seems only to reach through the header information from the browser. 
> Also I've learned through SelfHTML that the MIME type support of 
> browsers has holes sometimes, as described for the accept attribute of 
> the  tag.
> Does anybody have further information on that issue, and why 
> headers['Content-Type'] isn't used by Zope (it is, in fact, but in 
> ZPublisher for seemingly other purposes)?

The File and Image objects use the Content-Type header on upload if it
is provided by the browser. Only if none is provided does it guess one.
See OFS.Image.File._get_content_type().

Florent
-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:[EMAIL PROTECTED]

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )



[Zope-dev] [Zope] Header information on file upload

2003-02-01 Thread Martin Gebert
Hi!

I already asked this question on the main Zope list, but there was no answer so far; so I hope I find the right audience here...

In my HowTo about dealing with BLOBs 
 I use a rather 
unelegant but working method to get the content type of an uploaded 
file. Stefan Tjarks has now drawn my attention to the Header attributes 
of the uploaded form data, namely the "Content-Type" attribute which 
seems to reveal the MIME type (photo.headers['Content-Type'] for the 
given exsample).
My sorrow is now that this information isn't 100 % reliable, 'cause the 
Zope core (esp. the Image and File classes) doesn't seem to use this 
possibility either, but implements it's own methods which I use in the 
HowTo, too. The responsible class ZPublisher.HTTPRequest.FileUpload 
seems only to reach through the header information from the browser. 
Also I've learned through SelfHTML that the MIME type support of 
browsers has holes sometimes, as described for the accept attribute of 
the  tag.
Does anybody have further information on that issue, and why 
headers['Content-Type'] isn't used by Zope (it is, in fact, but in 
ZPublisher for seemingly other purposes)?

Martin



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )