Streaming ZIPPED files

M

Mark Kelly

Hi (apologies for the xpost, but im not sure where this fits in),

I have recently had a site demostrated to me (a newsgroup binaries archive
site) that allows a user to select multiple files, then download the
selected files combined as one zip. At first i thought this was nothing
special, until it was pointed out that the download commenced immediately,
and some of the many selected files were almost a GB in size. The only
conclusions I can draw from this is that either a) they have a super-fast
zip service working in the background (which i think is unlikely), or b) you
can somehow 'stream' a zip file as it is created - which i think is the more
likely option. I've noticed that none of the zips are compressed and was
wondering if its possible to somehow add a zip header to the response,
followed by binarywrites of the selected files?

If anybody can shed any light (point me in the direction of
articles/components/examples) on how to do this using c#/asp.net I would
really appreciate it.

tia.

Mark Kelly
 
J

Jerry Pisk

Yes it is possible to create zip files on the fly, the actual implementation
will depend on which zip library you use, since .Net framework doesn't come
with one.

Jerry
 
M

Mark Kelly

Hi Jerry

I understand that its possible to create zip files on the fly, I'm wondering
how you start sending the zip to the client, before you've finished creating
it!
 
E

Ed Courtenay

Mark said:
Hi Jerry

I understand that its possible to create zip files on the fly, I'm wondering
how you start sending the zip to the client, before you've finished creating
it!

If you use the SharpZipLib library, you create a ZipOutputStream which
you wrap around an exisiting stream and then write to it using standard
StreamWriter classes.

As you write data to the ZipOutputStream, it's compressed on the fly and
sent to its eventual destination. In this way, you don't even have to
create a local file before sending it to the remote client!
 
M

Mark Kelly

Cheers Ed - this is exactly what i was looking for.

Ed Courtenay said:
Mark said:
Hi Jerry

I understand that its possible to create zip files on the fly, I'm wondering
how you start sending the zip to the client, before you've finished creating
it!

If you use the SharpZipLib library, you create a ZipOutputStream which
you wrap around an exisiting stream and then write to it using standard
StreamWriter classes.

As you write data to the ZipOutputStream, it's compressed on the fly and
sent to its eventual destination. In this way, you don't even have to
create a local file before sending it to the remote client!



--

Ed Courtenay
[MCP, MCSD]
http://www.edcourtenay.co.uk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top