1

I am uploading to azure storage a collection of files, as a single "entity". I have a requirement to provide this collection as an option to download each individual file separately, or as bundled zip of the files. I'd like the files to be served directly by azure if possible.

Firstly, there are a few alternate but undesirable options I've considered:

  • Upload all of the individual files to azure as separate blobs, plus upload a separate zip file containing all of them. undesirable, duplicate files in azure storage, but minimal server load (only needs to upload the files twice, then files served strictly from azure)
  • Upload them only as separate file, and have them pass through my external server to bundle them, or vice versa. undesirable, uses my server bandwidth and cpu cycles every time, also potentially slower serving the bundle depending on server load

Ideally, I'd like to only upload them as a pre-packaged zip, include a custom blob DEFLATE header (to hint to the browser that these files are served compressed), and in the metadata specify the starting offset and compressed length of each file. If there was a way to specify the range header in a get parameter it would be perfect, for an image I could emit html like:
<img src="azure.endpoint/container/somecollection.zip?range=256-542"/>
where 256-542 was the binary location of the image within the zip, and chrome would take care of downloading, decompressing, and displaying the image - unfortunately I've found no api to do this with azure.

It seems that the alternative would be to use ajax calls, specifying the Range header, using some kind of javascript deflate library, and then loading it with base64 data-uris. So my questions are as follows:

  • where can i get started to actually do such a thing with ajax and javascript? I played around with getting pako to work to deflate, but I've not been able to get this working in the browser after many failed attempts.
  • what would the performance considerations be if i was loading lots of large images like this, say 20 images of 20MB's each?
  • would this also void any browser caching that takes place and is there any considerations there?
  • is there an alternative option I've overlooked provided the requirements?
caesay
  • 16,932
  • 15
  • 95
  • 160
  • Would there be a requirement that a user may choose to download complete zip file sometimes and download an individual blob from that zip file sometimes? Recently we did some work in our product where we downloaded individual blob contents and kept in browser's memory and once the contents are downloaded, we zipped them in browser only and prompted the user to download the zip file. – Gaurav Mantri Mar 07 '16 at 03:49
  • @GauravMantri: yes, the user can choose to either download it as a full zip, or just a single file. I'm not opposed to downloading the files and creating the zip in the browser, if you have some examples that would be cool. The biggest problem is that I'd be limited essentially to a certain file size.. since file apis are largely inconsistent across browsers, the zipping would have to be done in memory, so I'd be limited by the memory allocated by the browser. – caesay Mar 07 '16 at 03:56
  • Possible duplicate of [Accessing partial response using AJAX or WebSockets?](http://stackoverflow.com/questions/7952448/accessing-partial-response-using-ajax-or-websockets) – Paul Sweatte Jun 22 '16 at 21:34

0 Answers0