Python CGI - Presenting a zip file to user

jwwest jwwest at gmail.com
Wed Jan 2 18:50:00 EST 2008


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



More information about the Python-list mailing list