コード例 #1
0
        public async Task <IUploadBlock> UploadBlock(IUpload upload, int number, Stream stream)
        {
            var partRequest = new UploadPartRequest(client.Region, upload, number);

            partRequest.SetStream(stream);

            return(await client.UploadPartAsync(partRequest).ConfigureAwait(false));
        }
コード例 #2
0
        public async Task <UploadPartResult> UploadPartAsync(UploadPartRequest request)
        {
            using HttpResponseMessage response = await SendAsync2(request, request.CompletionOption).ConfigureAwait(false);

            return(new UploadPartResult(
                       uploadId: request.UploadId,
                       partNumber: request.PartNumber,
                       eTag: response.Headers.ETag.Tag
                       ));
        }
コード例 #3
0
 public async Task <UploadPartResult> UploadPartAsync(UploadPartRequest request)
 {
     using (var response = await SendAsync2(request).ConfigureAwait(false))
     {
         return(new UploadPartResult(
                    uploadId: request.UploadId,
                    partNumber: request.PartNumber,
                    eTag: response.Headers.ETag.Tag
                    ));
     }
 }
コード例 #4
0
        public async Task <IUploadBlock> UploadBlock(IUpload upload, int number, Stream stream)
        {
            #region Preconditions

            if (upload == null)
            {
                throw new ArgumentNullException(nameof(upload));
            }

            #endregion

            var request = new UploadPartRequest(client.Host, upload, number);

            request.SetStream(stream);

            return(await client.UploadPartAsync(request).ConfigureAwait(false));
        }
コード例 #5
0
ファイル: S3Bucket.cs プロジェクト: jweissBHG/Amazon
        public async Task <IUploadBlock> UploadPartAsync(IUpload upload, int number, Stream stream)
        {
            if (upload is null)
            {
                throw new ArgumentNullException(nameof(upload));
            }

            var request = new UploadPartRequest(
                host: client.Host,
                bucketName: upload.BucketName,
                key: upload.ObjectName,
                uploadId: upload.UploadId,
                partNumber: number
                );

            request.SetStream(stream);

            return(await client.UploadPartAsync(request).ConfigureAwait(false));
        }
コード例 #6
0
ファイル: S3Bucket.cs プロジェクト: NemesisGames/Amazon
        public async Task <IUploadBlock> UploadPartAsync(IUpload upload, int number, Stream stream)
        {
            if (upload is null)
            {
                throw new ArgumentNullException(nameof(upload));
            }

            int       retryCount = 0;
            Exception lastException;

            do
            {
                if (retryCount > 0)
                {
                    await Task.Delay(retryPolicy.GetDelay(retryCount)).ConfigureAwait(false);
                }

                var request = new UploadPartRequest(
                    host: client.Host,
                    bucketName: upload.BucketName,
                    key: upload.ObjectName,
                    uploadId: upload.UploadId,
                    partNumber: number
                    );

                request.SetStream(stream);

                try
                {
                    return(await client.UploadPartAsync(request).ConfigureAwait(false));
                }
                catch (S3Exception ex) when(ex.IsTransient)
                {
                    lastException = ex;
                }

                stream.Position = 0;

                retryCount++;
            }while (retryPolicy.ShouldRetry(retryCount));

            throw lastException;
        }