Mescal
Mescal

Reputation: 123

How to zip huge files in a blob using stream

I'm using Azure with blob storage ans Azure Functions. I got a lot of files and sometimes I want to generate a zip, save it in the storage and generate a link.

As my zip can be big (1 or 2 Go) I would like to do this "on the fly", meaning without using all the memory before save it:

stream on a zipentry
write to the blob
flush the stream
create next zipentry

I know I must use the method PutBlock() in the container, but I'm missing the code between ICSharpZipLib and BlobContainer.

Has someone an idea about it ?

Upvotes: 3

Views: 2087

Answers (1)

Mescal
Mescal

Reputation: 123

Well, if I look more attentively at the documentation, I would have seen the method

blob.OpenWrite()

which returns a stream :

using (ZipOutputStream zipStream = new ZipOutputStream(blob.OpenWrite()))

Then I did as usual.

Upvotes: 4

Related Questions