I guess I could try this out before asking, but just wanted to be sure it was even possible before I wasted any time.
I'm trying to eliminate the need for an in memory or physical file buffer. I want to download a file via HTTP, or FTP (or anything for that matter) and as the stream is getting filled, I want simultaneously start uploading that stream (via HTTP, FTP, etc) to somewhere else.
Is this even possible in .NET? The only way I can think of doing that "traditionally" is to first allow the stream to finish, and then copy that stream from memory into another stream, but I want to use the least amount of resources (time, memory, etc) as possible.
This is entirely possible, no problem; but you wouldn't use the same stream, you would use two different ones, and pipe data from the input to the output in a loop.
Should be fine. Recent versions of .Net support Stream.CopyToAsync(otherStream)
(or its non-async counterpart), which is pretty much a complete solution for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With