Method AddAsync
AddAsync(FileStream, bool, IFileProcessingPipelineSelector, CancellationToken)
Adds a new file to the repository from the specified file stream, taking the extension from the stream's file name, and processes it through the specified pipeline.
Declaration
TaskWithProgress<IRepoFileGroup> AddAsync(FileStream stream, bool leaveOpen, IFileProcessingPipelineSelector pipeline, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| FileStream | stream | The source file stream. |
| bool | leaveOpen | Indicates whether to leave the stream open after the operation completes. |
| IFileProcessingPipelineSelector | pipeline | The processing pipeline, or the selector that chooses one by extension. |
| CancellationToken | cancellationToken | A cancellation token that cancels the operation. |
Returns
| Type | Description |
|---|---|
| TaskWithProgress<IRepoFileGroup> | The resulting file group, including the main file and any variants declared by the pipeline. |
Remarks
AddAsync(Stream, string, bool, IFileProcessingPipelineSelector, CancellationToken)
Adds a new file to the repository from the specified stream and extension, and processes it through the specified pipeline.
Declaration
TaskWithProgress<IRepoFileGroup> AddAsync(Stream stream, string extension, bool leaveOpen, IFileProcessingPipelineSelector pipeline, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The source stream. |
| string | extension | The source file extension including the leading period, or an empty string if it has none. |
| bool | leaveOpen | Indicates whether to leave the stream open after the operation completes. |
| IFileProcessingPipelineSelector | pipeline | The processing pipeline, or the selector that chooses one by extension. |
| CancellationToken | cancellationToken | A cancellation token that cancels the operation. |
Returns
| Type | Description |
|---|---|
| TaskWithProgress<IRepoFileGroup> | The resulting file group, including the main file and any variants declared by the pipeline. |
Remarks
The file is added exactly as by AddAsync(Stream, string, bool, IFileProcessingPipelineSelector, CancellationToken) and is committed or rolled back together with the transaction's deletions.
The files of the returned group know their sizes without storage access or a network round trip (see GetLengthAsync(CancellationToken)).
Exceptions
| Type | Condition |
|---|---|
| FileProcessingException | A processor in the pipeline rejected or failed to process the source. |
| FileSourceUnchangedException | The pipeline made no changes to the source and its ThrowWhenMainSourceUnchanged option is set. |
| InvalidOperationException | The transaction has been staged or rolled back. |
| ObjectDisposedException | The transaction has been disposed. |