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

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

Returns a stream from which the caller can read the content from the specified Amazon S3 bucket and key. The caller of this method is responsible for closing the stream.
public OpenStreamAsync ( string bucketName, string key, CancellationToken cancellationToken = default(CancellationToken) ) : Task
bucketName string /// The name of the bucket. ///
key string /// The object key. ///
cancellationToken System.Threading.CancellationToken /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. ///
Результат Task
        public Task<Stream> OpenStreamAsync(string bucketName, string key, CancellationToken cancellationToken = default(CancellationToken))
        {
            TransferUtilityOpenStreamRequest request = new TransferUtilityOpenStreamRequest()
            {
                BucketName = bucketName,
                Key = key
            };
            return OpenStreamAsync(request, cancellationToken);
        }

Same methods

TransferUtility::OpenStreamAsync ( Amazon.S3.Transfer.TransferUtilityOpenStreamRequest request, 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);
         }
     }
 }