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?