Beispiel #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));
        }
Beispiel #2
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));
        }
Beispiel #3
0
        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));
        }
Beispiel #4
0
        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;
        }