开发者

Split zip file using DotNetZip Library

开发者 https://www.devze.com 2023-03-11 05:51 出处:网络
I\'m using DotNetZip Library to create a zip file with about 100MB.I\'m saving the zip file directly to the Response.OutputStream

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号