mirror of https://github.com/abpframework/abp.git
Browse Source
2. remove all rewinds related to streams; the user is the one who must ensure his streams are at the correct position when calling the api; stream rewind would exclude the ability of sending partial streams (at least skippable streams, because the tail cannot be limitted in .net core) 3. RemoteStreamContent now must get the content type associated with the stream in its constructor; it may also receive the length of the stream in a read-only form (this is because some stream classes cannot provide the length and it is provided via http headers) 4. IRemoteStreamContent should implement IDisposable to allow the auto clean up of streams (example: FileStream)pull/9180/head
11 changed files with 130 additions and 86 deletions
@ -0,0 +1,29 @@ |
|||
using System.IO; |
|||
|
|||
public static class StreamExtensions |
|||
{ |
|||
public static long? GetNullableLength(this Stream stream) |
|||
{ |
|||
try |
|||
{ |
|||
return stream?.Length; |
|||
} |
|||
catch |
|||
{ |
|||
/*some stream classes throw exceptions when accessing Length because they do not have access to such information */ |
|||
return null; |
|||
} |
|||
} |
|||
public static long? GetNullablePosition(this Stream stream) |
|||
{ |
|||
try |
|||
{ |
|||
return stream?.Position; |
|||
} |
|||
catch |
|||
{ |
|||
/*some stream classes throw exceptions when accessing Position because they do not have access to such information */ |
|||
return null; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue