Amazon.S3.Transfer.TransferUtility.OpenStreamAsync C# (CSharp) Метод

OpenStreamAsync() публичный Метод

Returns a stream to read the contents from Amazon S3 as specified by the TransferUtilityOpenStreamRequest. The caller of this method is responsible for closing the stream.
public OpenStreamAsync ( Amazon.S3.Transfer.TransferUtilityOpenStreamRequest request, CancellationToken cancellationToken = default(CancellationToken) ) : Task
request Amazon.S3.Transfer.TransferUtilityOpenStreamRequest /// Contains all the parameters required for the OpenStream operation. ///
cancellationToken System.Threading.CancellationToken /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. ///
Результат Task
        public async Task<Stream> OpenStreamAsync(TransferUtilityOpenStreamRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            OpenStreamCommand command = new OpenStreamCommand(this._s3Client, request);
            await command.ExecuteAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
            return command.ResponseStream;
        }

Same methods

TransferUtility::OpenStreamAsync ( string bucketName, string key, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Usage Example

Пример #1
2
 private async Task ReadObject(Stream stream, CancellationToken ct, string key)
 {
     using (var util = new TransferUtility(_s3))
     {
         using (Stream srcStream = await util.OpenStreamAsync(_bucket, key).ConfigureAwait(false))
         {
             await srcStream.CopyToAsync(stream, 64*1024, ct).ConfigureAwait(false);
         }
     }
 }