This is probably explained somewhere on the web but I cant find it. What exactly is a StreamContent?
(I'm trying to understand C# but I cant properly understand some WebAPi examples cos I dont understand what a StreamContent is.
A link that fully explains it (and not just list its properties etc like MSDN) would be fine.
This is an old post, but came across it so perhaps it may help others: StreamContent
is a content type that can be used to set the .Content
property on a HttpResponseMessage
. This indicates to the web process that the content is to be streamed from a source stream (a readable stream) to the client. For example, you could open a FileStream
and pass it to the constructor of StreamContent, then set that onto the .Content
property. This will tell the server to read from the FileStream
and stream the content down to the client, chunk by chunk. This is often preferred vs. reading the (potentially large) source stream (the file) into ram first and then returning an array (in which case the web server must use RAM to hold the file and feed it down to the client).
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