使用 DotNetZip 库分割 zip 文件

发布于 2024-11-14 18:18:39 字数 1152 浏览 3 评论 0原文

我正在使用 DotNetZip Library 创建一个大约 100MB 的 zip 文件。我将 zip 文件直接保存到 我需要的Response.OutputStream

Response.Clear();
    // no buffering - allows large zip files to download as they are zipped
    Response.BufferOutput = false;
    String ReadmeText= "Dynamic content for a readme file...\n" + 
                       DateTime.Now.ToString("G");
    string archiveName= String.Format("archive-{0}.zip", 
                                      DateTime.Now.ToString("yyyy-MMM-dd-HHmmss")); 
    Response.ContentType = "application/zip";
    Response.AddHeader("content-disposition", "attachment; filename=" + archiveName);
    using (ZipFile zip = new ZipFile())
    {
        // add a file entry into the zip, using content from a string
        zip.AddFileFromString("Readme.txt", "", ReadmeText);
        // add the set of files to the zip
        zip.AddFiles(filesToInclude, "files");
        // compress and write the output to OutputStream
        zip.Save(Response.OutputStream);
    }
    Response.Close();

是将这个 100MB 文件分成大约 20MB 的部分,并向用户提供下载工具。我怎样才能实现这一点?

I'm using DotNetZip Library to create a zip file with about 100MB.I'm saving the zip file directly to the Response.OutputStream

Response.Clear();
    // no buffering - allows large zip files to download as they are zipped
    Response.BufferOutput = false;
    String ReadmeText= "Dynamic content for a readme file...\n" + 
                       DateTime.Now.ToString("G");
    string archiveName= String.Format("archive-{0}.zip", 
                                      DateTime.Now.ToString("yyyy-MMM-dd-HHmmss")); 
    Response.ContentType = "application/zip";
    Response.AddHeader("content-disposition", "attachment; filename=" + archiveName);
    using (ZipFile zip = new ZipFile())
    {
        // add a file entry into the zip, using content from a string
        zip.AddFileFromString("Readme.txt", "", ReadmeText);
        // add the set of files to the zip
        zip.AddFiles(filesToInclude, "files");
        // compress and write the output to OutputStream
        zip.Save(Response.OutputStream);
    }
    Response.Close();

what i need is to split this 100MB file in to with about 20MB sections and provide the download facility to the user.how can i achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮年 2024-11-21 18:18:39

你的问题有点独立于 ZIP 方面。基本上,您似乎想要提供 100mb 或更多的大文件可供下载,并且您想要分部分进行。一些选项:

  • 将其保存到常规文件,然后分部分传输。客户端必须对 N 个部分中的每个部分发出不同的下载请求,通过 HTTP 范围标头。必须将服务器设置为使用适当的 MIME 类型等来服务器 ZIP 文件。

  • 将其保存到 分割(跨区)zip 文件,这意味着 N 个不同的文件。然后,客户端将为每个不同的文件进行 HTTP GET。服务器必须设置为服务器 .zip、.z00、.z01 等。我不确定内置操作系统工具是否可以正确处理拆分 zip 文件。

  • 将文件另存为一个大 blob,并让客户端使用 BITS 或其他一些可重新启动的下载工具。

Your question is sort of independent of the ZIP aspect. Basically it seems you want to make available for download a large file of 100mb or more, and you want to do it in parts. Some options:

  • Save it to a regular file, then transmit it in parts. The client would have to make a distinct download request for each of the N parts, selecting the appropriate section of the file via the HTTP Range header. The server would have to be set up to server ZIP files with the appropriate MIME type etc.

  • save it to a split (spanned) zip file, which implies N different files. The client would then make an HTTP GET for each of the distinct files. The server would have to be set up to server .zip, .z00, .z01, etc. I'm not sure if built-in OS tools handle split zip files appropriately.

  • save the file as one large blob, and have the client use BITS or some other restartable download facility.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文