[Zope] retrieving a blob stored file from mysql

J Cameron Cooper jccooper at jcameroncooper.com
Thu Oct 2 19:35:25 EDT 2003


>I am trying to implement a feature on my site where users can upload a
>file (typically a tif file) for other users to download.  I have the
>upload working fine and the download side works with Linux with Mozilla
>(my development system) but IE6 won't open the file as if it were a
>regular link.  When you choose "save as" it works but if you choose
>"open with" to open the file with some kind of image viewer Windows
>complains that the temporary file does not exist.  
>
>This is what I'm doing:
>1. I link to my python script from my dtml document
><a
>href="get_attachment?attachment_id=&dtml-attachment_id;">&dtml-doc_name;</a>
>
>2. get_attachment
>result = context.sqlSelAttachmentByID(attachment_id = attachment_id)
>container.REQUEST.RESPONSE.setHeader('content-type', result[0].type)
>container.REQUEST.RESPONSE.setHeader('content-disposition',
>'attachment;filename=' + result[0].doc_name)
>#content-disposition can use either: application, inline, or attachment
>return result[0].attachment
>
IE (and/or Windows) is known to almost religiously ignore any attempts 
by the server to tell it what type some content is other than its filename.

When you "save as" it will realize what it is looking at, but when being 
presented "inline" you are generally at the mercy of file extensions. 
You may need to find a way for your link to end in '.tif' or whatever it 
really is. Problems with this OS misfeature are dreadfully common.

             --jcc

-- 
"Code generators follow the 80/20 rule. They solve most of the problems, but not all of the problems. There are always features and edge cases that will need hand-coding. Even if code generation could build 100 percent of the application, there will still be an endless supply of boring meetings about feature design."
(http://www.devx.com/java/editorial/15511)





More information about the Zope mailing list