如何使用流将大文件压缩为Blob [英] How to zip huge files in a blob using stream

查看:252
本文介绍了如何使用流将大文件压缩为Blob的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Azure与Blob存储和Azure Functions一起使用. 我有很多文件,有时我想生成一个zip文件,将其保存在存储中并生成一个链接.

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.

由于我的zip可能很大(1或2 Go),因此我想即时"执行此操作,这意味着在保存之前无需使用所有内存:

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

我知道我必须在容器中使用方法PutBlock(),但是我错过了ICSharpZipLib和BlobContainer之间的代码.

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

有人对此有想法吗?

推荐答案

好吧,如果我更专心地阅读文档,我会看到该方法的

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

blob.OpenWrite()

返回流:

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

然后我像往常一样做.

这篇关于如何使用流将大文件压缩为Blob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆