Method FromStreamFactory
FromStreamFactory(string, long, Func<CancellationToken, Task<Stream>>, string?)
Creates a source that reads streams that a function opens, one read at a time. It keeps a stream open between reads and reads it forward, setting
its position if it is seekable. It opens a new stream to go back in one that is not seekable, after a read fails, and after
ReleaseAsync(). A stream whose length differs from length fails the read with an IOException.
Declaration
public static UploadSource FromStreamFactory(string fileName, long length, Func<CancellationToken, Task<Stream>> openAsync, string? contentType = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileName | The name of the file, which the service receives. |
| long | length | The length of the content in bytes. |
| Func<CancellationToken, Task<Stream>> | openAsync | A function that opens a readable stream of the content, positioned at its start. The source disposes the streams. |
| string | contentType | The content type of the file, such as |
Returns
| Type | Description |
|---|---|
| UploadSource |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
| ArgumentOutOfRangeException |
|