W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2011

Enable compression of a blob to .zip file

From: Alfonso Martínez de Lizarrondo <amla70@gmail.com>
Date: Sun, 30 Oct 2011 11:03:27 +0100
Message-ID: <CAH_vUwaG8YoRPTtOqR+1dnEowwedbEwRs_qBcTpqnc_uqyrBRQ@mail.gmail.com>
To: Webapps WG <public-webapps@w3.org>
Hi all

I've tried to search the Webapps and WHATWG mailing lists for previous
discussions about this request, but I haven't been able to find anything.

My request can be explained easily: when uploading files to the server,
many times the upload time can be improved greatly if the file is
compressed instead of sent as-is; in my case I've adjusted some systems
that requires the user to upload a data file so it can accept both the
original file (mdb, csv, .xls, ....), or a compressed version in .zip

When the user remembers to compress the zip everything goes fine, but many
times people might not be aware of that option, and so I think that it
would be useful to have an option (whatever objects or proposal about
methods are just quick ideas to explain the concept) on a Blob object to
compress it to a .zip and so get a new Blob

So the flow would be
1. User picks his data file with <input type=file>
2. JS starts a XHR upload to show a progress bar
3. JS checks that the file is uncompressed, so it creates a zipped blob:

var file = input.files[0];
var extension = file.name.match( /\.([^\.]+)\s*$/ )[ 1 ];
if (extension.toLowerCase() != 'zip') file = file.toZip( 'compressed.zip' );
formData.append( file );

4. And the rest of the upload goes as usual.
5. The server gets the file and uncompresses it (the server doesn't really
care if the file was compressed in js or because the user did it, but the
js code can add a flag in the xhr upload to signal that it was

Instead of a method on a Blob, it could be a separate object similar to
Mozilla nsIZipWriter (https://developer.mozilla.org/en/nsIZipWriter), but
with some simplifications to avoid extra verbose code.
var zipWriter = new zipWriter( 'compressed.zip' );
// This way it could be possible to add several files into the zip
zipWriter.addEntryFile( file);
formData.append( zipWriter );

Of course, in the files should be always added at the root of the zip
without any info about the original path. The compression can (and probably
should) be done asynchronously.

Would it be possible to add this new feature to some spec?
Received on Sunday, 30 October 2011 10:03:56 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:36 UTC