I need to create a service that returns a GZipStream consisting of one or more files. The number of files can be hundreds, and each file can occupy more than 500 MB.
How can I dynamically add files to gzipstream while streaming? (to avoid using an exception from memory when files need to be copied to a stream)
Etc:
- Copy file A to the returned stream.
- The client begins reading the stream.
- When file A has been read (client side), copy file B to the stream (server side).
- The client continues to read the stream.
... and so on, until there are no more files.
Btw. it doesn't matter that the files are compressed, they are simply combined into a zip file, so the client only needs to download one file.
Thus, my goal is to transfer several files back to the client as a single file without simultaneously processing all the files on the server (so as not to load all the files into memory and, therefore, not to create an exception from memory).
Could this be done by creating a custom thread in any way, or is there an easier way to go?
Thanks.
source share