Hi, Johan Carlsson wrote:
Johan Carlsson wrote at 2004-9-3 08:55 +0200:
For Images you can use
from Globals import ImageFile file=ImageFile('www/image.gif', globals())
Despite its name, you can use "ImageFile" for arbitrary files and not only for images.
Provide it actually can guess the content_type.
I'm running zope 2.6.4, python 2.2.3 on debian sarge. file = ImageFile('www/applet.jar', globals()) produced the following http headers - Content-Type: application/x-java-archive For PDF files, it produced "application/pdf" and for MS Word documents it produces "application/msword". ImageFile is pretty clever :-)
I would subclass ImageFile and override the __init__ with an extra content_type argument. But that's me :-)
I found that on debian I can make ImageFile understand new content types simply by modifying /etc/mime.types. Thanks to everyone for helping. - Raja