WebAPI中HttpContent: StreamContent 和 PushStreamContent 的使用场景

refs:

http://stackoverflow.com/questions/16168683/webapi-streamcontent-vs-pushstreamcontent

https://github.com/bUKaneer/bluimp-jquery-file-upload-with-mvc4-and-webapi

http://www.strathweb.com/2013/01/asynchronously-streaming-video-with-asp-net-web-api/

https://www.strathweb.com/2013/01/asynchronously-streaming-video-with-asp-net-web-api/

 

PushStreamContent is for scenarios where you need to 'push' data to the stream, where as StreamContent 'pulls' data from the stream. 

 

example:

if I want to "stream" content in the "streaming video" sense of the word use PushStreamContent but if I want to let someone "download a file" then use StreamContent

The "streaming video" scenario is one, where you do not know the total content length upfront and you are writing to the destination stream as you are receiving the video feed from somewhere. This is the reason when using PushStreamContent response is sent in chunked transfer encoding as we do not know the content length upfront. 

 

 

 

 

你可能感兴趣的:(c#)