How to reconcile these two APIs when dealing with streams without hogging up memory?

48 views Asked by At

I'm using the Iconic Zip Library to do some zipping.

When it's time to zip up, I want to call their ZipFile.Save(Stream outputStream) method.

On the Telligent side, to save the content of a stream to a file you use their ICentralizedFileStorageProvider.AddUpdateFile(string path, string fileName, Stream contentStream) method.

As you can see, you provide the Iconic Zip Library a stream for them to write to, but to save a file, Telligent does not provide you with a stream for you to write to, you need to provide them with a stream for them to read from.

Sure, I could use a MemoryStream, load it by passing it the Iconic Zip Library and then unload it by passing it to the Telligent APIs, but that would cause the entire zip file to be loaded to memory all at once. I know that the final zip is going to be huge, so loading it entirely onto memory is not an option; I need to do some sort of buffering.

How do I reconcile these two APIs? How do I build a bridge between them where data can flow without hogging up memory? Any ideas?

0

There are 0 answers