I have a readonly System.IO.Stream implementation that is not seekable (and its Position always returns 0). I need to send it to a consumer that do
I just use the MakeStreamSeekable method from the Amazon SDK:
Converts a non-seekable stream into a System.IO.MemoryStream. A MemoryStream's position can be moved arbitrarily.
C#
public static Stream MakeStreamSeekable(
Stream input
)
*input* ([Stream][2])
The stream to be converted
A seekable MemoryStream
MemoryStreams use byte arrays as their backing store. Please use this judicially as it is likely that a very large stream will cause system resources to be used up.