[Zope] Returning a zip file (downloaded by user)??
Jan-Wijbrand Kolman
jw@infrae.com
Tue, 30 Jul 2002 22:41:43 +0200
Hi Aseem,
These headers are set by an app I worked on (although I didn't do
the zipfile-download-thingy myself). Hope these work for you too...
REQUEST.RESPONSE.setHeader('Content-Type', 'application/zip')
REQUEST.RESPONSE.setHeader('Content-Length', file_size)
REQUEST.RESPONSE.setHeader('Content-Disposition', 'inline;
filename=%s' % the_name_of_the_file)
Another difference: the download method in aformentioned app does
not "REQUEST.RESPONSE.write(data)", but just "returns" the data,
after setting the headers.
regards,
jw
--
Jan-Wijbrand Kolman
jw@infrae.com
On Tuesday, July 30, 2002, at 10:01 , Aseem Mohanty wrote:
> Hi,
> I have a zip file that I create on the fly which is to be returned
> to the user. The process goes like this:
>
> 1. User clicks on a link.
> 2. External method creates a zip file and puts it in a temp folder
> ( file system folder not Zope temp)
> 3. External method (same one) returns the zip file as part of
> response as type application/x-zip
>
> The following is what I do in to get it done:(part 3 i.e.)
>
> zip_size = stat(zip_file_name).st_size
> zip_file = open(zip_file_name)
> zip_data = zip_file.read()
> zip_file.close()
> REQUEST.RESPONSE.setStatus('OK')
> REQUEST.RESPONSE.setHeader('Content-Type','application/x-zip')
> REQUEST.RESPONSE.setHeader('Content-Length',zip_size)
> REQUEST.RESPONSE.write(zip_data)
>
> but when I try it out the following happens:
> - the zip file is created
> - zip_data has the data (of course)
> - i am prompted to download something of type
> application/x-unknown-content
> - if i save the file it has zero length
>
> so what am I doing wrong or not doing here, that needs to be done
> to get this right??
> TIA
> AM
>
> -- ==================================================================
> Aseem Mohanty Neurobehavioral Systems
> Inc, 828 San Pablo Ave, Albany, CA 94706 (R) 510 7696011 (M) 510
> 3014871 (O) 510 5279231
> ==================================================================
>
> "I saw `cout' being shifted "Hello world" times to the left and
> stopped right there!!" -- Steve
> Gonedes ================================================================
> ==
>
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )