Пример #1
0
        public async Task <IUpload> InitiateUploadAsync(string key, IReadOnlyDictionary <string, string> properties)
        {
            int       retryCount = 0;
            Exception lastException;

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

                var request = new InitiateMultipartUploadRequest(client.Host, bucketName, key, properties);

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

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

            throw lastException;
        }
Пример #2
0
        public async Task <IUpload> InitiateUploadAsync(string key, IReadOnlyDictionary <string, string> properties)
        {
            var request = new InitiateMultipartUploadRequest(client.Host, bucketName, key)
            {
                Content = new StringContent(string.Empty)
            };

            SetHeaders(request, properties);

            return(await client.InitiateMultipartUploadAsync(request).ConfigureAwait(false));
        }
Пример #3
0
        // TODO: Introduce IUpload in Carbon.Storage

        // TODO:
        // Carbon.Storage.Uploads
        // - IUpload (bucketName, objectName, uploadId)
        // - IUploadBlock (uploadId, number, state)

        public async Task <IUpload> StartUploadAsync(string name, IReadOnlyDictionary <string, string> metadata)
        {
            var request = new InitiateMultipartUploadRequest(client.Region, bucketName, name)
            {
                Content = new StringContent(string.Empty)
            };

            SetHeaders(request, metadata);

            return(await client.InitiateMultipartUploadAsync(request).ConfigureAwait(false));
        }
Пример #4
0
        // TODO: Introduce IUpload in Carbon.Storage

        // TODO:
        // Carbon.Storage.Uploads
        // - IUpload (bucketName, objectName, uploadId)
        // - IUploadBlock (uploadId, number, state)

        public async Task <IUpload> StartUploadAsync(string name, IReadOnlyDictionary <string, string> metadata)
        {
            #region Preconditions

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

            #endregion

            var request = new InitiateMultipartUploadRequest(client.Host, bucketName, name)
            {
                Content = new StringContent(string.Empty)
            };

            SetHeaders(request, metadata);

            return(await client.InitiateMultipartUploadAsync(request).ConfigureAwait(false));
        }