[mod_python] streaming zipped data with publisher

Sean Jamieson sean at barriescene.com
Sat Jan 7 16:55:55 EST 2006


Sure it is, even with the temporary file option, all you have to do is 
set the content-type header to application/x-gzipped or something like 
that (application/octet-stream is always a fallback value; this forces 
download, and doesn't allow it to recognize the file format for use with 
an external application), then output the file (possibly setting the 
Content-Length header first, to be polite)

with or with out the file is your choice, all you have to do is output 
the binary data, and no other output (not even a single space) or you 
will corrupt it.

Daniel Nogradi wrote:

>Is it possible to "stream" zipped data using the publisher handler?
>
>In my situation I would create the zipped archive upon client input
>and want to return the archive immediately. What I have in mind is
>creating a zip archive (using the zipfile module perhaps) in memory
>and than sending that to the client without actually creating a zip
>file on the disk of the server.
>
>In case this would not be possible I could live with creating a
>temporary file and returning that to the client, but at the moment the
>only way I can do this is through a link (such as <a
>href='data.zip'>click here</a>)  but in this case it would be a 2-step
>process: (1) user clicks on something which creates the archive and
>sends back the link in html (2) user clicks on the link. Is it not
>possible to send the zip file immediately after its creation?
>
>_______________________________________________
>Mod_python mailing list
>Mod_python at modpython.org
>http://mailman.modpython.org/mailman/listinfo/mod_python
>
>
>  
>



More information about the Mod_python mailing list