I have a directory structure with a huge number of data/files (>100Mb) that I want a Web client to be able to download, so I ZIP all the files into one file and transmit it to the user. However there is one problem…it takes quite some time to generate the zipfile, so I want to start sending (streaming) it to the client right away (while the zip file is still written) using another thread (I guess).
Is this possible and does there exists a pattern/example for doing it??
Any help would be greatly appreciated….
Imported from legacy forums. Posted by smolesen (had 2188 views)
The current implementation always work with temp files (either the default DiskFolder, or a MemoryFolder, or any other kind of AbstractFolder).
There is an optimization in the plans when dealing with a freshly created zip file that could represent exactly what you need. If the zip file is new, we would enable creating the zip file directly in the target AbstractFile. In your case, creating a StreamFile around your NetworkStream (e.g. obtained from Response.OutputStream) as your target zip file would do the job.
There would be limitations with this optimization: The FileSystem is an open system. For example, within a ZipArchive.BeginUpdate / ZipArchive.EndUpdate block, nothign prevents you from copying a DiskFile into a ZippedFile, then change the ZippedFile attributes or dates. With the optimization, you won’t be able to change any metadata once the source file is copied in the destination.
Unfortunately, I cannot give you any timeframe, as we haven’t started work on this.
If you are currently zipping on disk, I can give you hints on how to improve performance by zipping in memory (both temp files and the real target), given that you have enough memory to withstand the demand!
Imported from legacy forums. Posted by Martin (had 2934 views)