示例#1
0
        public async Task <MultipartUploadStatus> ExecuteMultipartAsync(CancellationToken token = default)
        {
            InitiateMultipartUploadRequest initReq = _request;

            initReq.Method = HttpMethod.POST;

            IAsyncEnumerable <UploadPartResponse> async = _objectOperations.MultipartUploadAsync(initReq, _request.Content, token: token);

            await foreach (UploadPartResponse resp in async.WithCancellation(token))
            {
                if (!resp.IsSuccess)
                {
                    return(MultipartUploadStatus.Incomplete);
                }
            }

            return(MultipartUploadStatus.Ok);
        }
示例#2
0
        public async Task <MultipartUploadStatus> MultipartUploadAsync(string bucketName, string resource, Stream data, int partSize = 16777216, int numParallelParts = 4, Action <InitiateMultipartUploadRequest> config = null, CancellationToken token = default)
        {
            InitiateMultipartUploadRequest req = new InitiateMultipartUploadRequest(bucketName, resource);

            config?.Invoke(req);

            IAsyncEnumerable <UploadPartResponse> asyncEnum = _operations.MultipartUploadAsync(req, data, partSize, numParallelParts, token);

            await foreach (UploadPartResponse obj in asyncEnum.WithCancellation(token))
            {
                if (!obj.IsSuccess)
                {
                    return(MultipartUploadStatus.Incomplete);
                }
            }

            return(MultipartUploadStatus.Ok);
        }