Mike Looijmans
nlv11281 at natlab.research.philips.com
Tue Mar 7 01:41:08 EST 2006
Practical example: import tarfile ... tar = tarfile.open(mode="w|", fileobj=req) for f in files: tar.add(f) tar.close() ... Use a mode of "w|gz" or "w|bz2" to enable gzip/bzip2 compression (see Python help or docs on tarfile for that) Note: On unix systems (linux), it is a wee bit faster to run the (g)tar program and stream its output, especially with lots of small files. On Windows systems, this just does not work reliably. Mike Looijmans Philips Natlab / Topic Automation Mike Looijmans wrote: > Use TarFile (python 2.3 or higher) instead of zip. > > Most "winzip" alike programs can handle TAR files just fine, so your > users won't notice the difference. TAR files are designed to be > streamable (Tape ARchive) and the python interface won't need tell(). > You can stream anything that supports read() to a TAR stream. > > TAR does not support compression, but it is common to (g)zip the tar > stream, which yields a streamable compressed result (and still delivers > a tar file on the other side if you use a content-encoding of x-gzip) > > Mike Looijmans > Philips Natlab / Topic Automation > > > jarrod roberson wrote: > >> just to stop the responses now mod_deflate is NOT what I need. I need >> the end user to get a pop up that allows them to down load the >> contents of a directory as one big zip file. >> >> I have a servlet in Java that does just this using the ZipOutputStream >> and it works great! You can download giant directorys with very very >> little load on the server since I am doing a ZERO level compression. >> >> The reason I am looking at a mod_python solution is the way we have >> mod_dav set up right now it takes over the namespace that we need to >> do redirects from and can't get Apache to redirect the URL to the Java >> Servlet, and we have a big time crunch and can't re-archtiect the >> entire directory layout to try and fix it right now. >> >> I saw a post recommending to use ZipFile, ZipFile won't work, it needs >> .tell(). It updates all the zip headers after the fact. >> I found something called zipstream.py, but alas, it does the same thing! >> >> Before I go and write a ZipOutputStream wrapper around the request >> object, I wanted to see if any of you know of anythign out there that >> does this. >> >> Thanks again, and remember mod_deflate is NOT going to work. > > > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python >
|