[Zope] Returning a zip file (downloaded by user)??
Aseem Mohanty
aseem@neurobehavioralsystems.com
Tue, 30 Jul 2002 01:01:03 -0700
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
==================================================================