How to zip huge files in a blob using stream

北战南征 提交于 2019-12-08 06:42:26

问题


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 ?


回答1:


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.



来源:https://stackoverflow.com/questions/46601443/how-to-zip-huge-files-in-a-blob-using-stream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!