469,338 Members | 8,616 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,338 developers. It's quick & easy.

Python CGI - Presenting a zip file to user

Hi all,

I'm working on a cgi script that zips up files and presents the zip
file to the user for download. It works fine except for the fact that
I have to overwrite the file using the same filename because I'm
unable to delete it after it's downloaded. The reason for this is
because after sending "Location: urlofzipfile" the script stops
processing and I can't call a file operation to delete the file. Thus
I constantly have a tmp.zip file which contains the previously
requested files.

Can anyone think of a way around this? Is there a better way to create
the zip file and present it for download "on-the-fly" than editing the
Location header? I thought about using Content-Type, but was unable to
think of a way to stream the file out.

Any help is appreciated, much thanks!

- James
Jan 2 '08 #1
1 1287
On Jan 3, 1:35 pm, jwwest <jww...@gmail.comwrote:
Thanks! That worked like an absolute charm.

Just a question though. I'm curious as to why you have to use the
msvcrt bit on Windows. If I were to port my app to *NIX, would I need
to do anything similar?

- James
not needed for *NIX as *NIX does not have a notion of binary- vs text-
mode

I seem to recall not needing the msvcrt stuff a while ago on Windows
but recently needed it again for Python CGI on IIS
Jan 3 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.