views:

640

answers:

2

I am looking for a way to dynamically stream download a zip of files from Amazon S3.

The application is hosted on EC2 and the files are stored on S3.

Need to give users the ability to select from a group of files which will then get bundled up and downloaded to them.

Have heard about a few Actionscript libraries (aszip and fzip) that might be possible, or could do this in Ruby, or even possibly PHP.

The files do not need any compression, zip is just being used to bundle the files up into one single download....

+1  A: 

If you can use Mono, DotNetZip will do it.

Response.Clear();
Response.BufferOutput= false;  // necessary for chunked output
String ReadmeText= "This content goes into an entry in the " +
                   "zip file.  Timestamp, MD5, whatever." ; 
string archiveName= String.Format("archive-{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss")); 
Response.ContentType = "application/zip";
Response.AddHeader("content-disposition", "filename=" + archiveName);

using (ZipFile zip = new ZipFile())
{
    zip.AddEntry("Readme.txt", "", ReadmeText, Encoding.Default);
    zip.AddFiles(filesToInclude, "files");
    zip.Save(Response.OutputStream);
}
HttpContext.Current.ApplicationInstance.CompleteRequest();

DotNetZip is open source, free to use.

Cheeso
A: 

Java supports streaming zips too. take a look at the java.utils.zip package. i used that to implement a pipline consisting of FTP, UNZIP, XSLT, CSV units. it works like a charm.

Martin

Martin Kirsch