Archived Forum Post

Index of archived forum posts


Possible to write zip entry from stream/buffer?

Feb 26 '15 at 12:37

In Chilkat Zip is it possible to write a zip entry by reading from a binary stream and write to a zip entry? I would like to avoid loading the entire data object into memory and writing all at once. With very large data sources this could cause problems loading the whole set into memory. I would like to loop through, filling a buffer, and writing the buffer contents to the zip entry until all the data has been read, then finalize the zip entry. Is it possible to do this?

Accepted Answer

No. I think the best choice is to write a temp file and then add the temp file to the zip via the AppendOneFileOrDir method (which just keeps a reference to the file and then when the .zip is written, it streams from the uncompressed temp file into the resultant zip).