/// <summary> /// Inititate a new Multipart upload request /// </summary> /// <param name="putObjectRequest"></param> /// <returns></returns> public async Task <MultipartManifest> NewRequest( string contentEncoding, string contentType, string contentLanguage, string contentDisposition, string cacheControl, Dictionary <string, string> metadata) { CheckInitialized(); var ifNoneMatch = _allowOverwrite ? null : "*"; var request = new CreateMultipartUploadRequest() { BucketName = _bucketName, NamespaceName = _namespaceName, IfNoneMatch = ifNoneMatch, CreateMultipartUploadDetails = new CreateMultipartUploadDetails() { Object = _objectName, ContentEncoding = contentEncoding, ContentType = contentType, ContentLanguage = contentLanguage, Metadata = metadata, ContentDisposition = contentDisposition, CacheControl = cacheControl, }, OpcClientRequestId = CreateClientRequestId("New") }; var response = await _service.CreateMultipartUpload(request).ConfigureAwait(false); _multipartManifest = new MultipartManifest(response.MultipartUpload.UploadId); _transferManager = new MultipartTransferManager(_multipartManifest, _service, _executorServiceToUse, _tokenSource.Token, _retryConfiguration); _initialized = true; return(_multipartManifest); }
/// <summary> /// Resumes an existing multi-part upload using the upload ID. /// </summary> /// <param name="uploadId"></param> /// <returns>MultipartManifest</returns> public async Task <MultipartManifest> ResumeUpload(string uploadId) { CheckInitialized(); var multipartUpload = FindUpload(uploadId); if (multipartUpload == null) { _logger.Error($"No matching upload found for ${uploadId}"); throw new ArgumentException($"Could not find existing upload with ID: {uploadId} in bucket: {_bucketName} and NamespaceName: {_namespaceName}"); } var multipartManifest = new MultipartManifest(uploadId); string nextPageToken = null; do { var partsRequest = new ListMultipartUploadPartsRequest() { BucketName = _bucketName, NamespaceName = _namespaceName, ObjectName = _objectName, UploadId = uploadId, Limit = 100, Page = nextPageToken, OpcClientRequestId = CreateClientRequestId("List") }; var existingParts = await _service.ListMultipartUploadParts(partsRequest, _retryConfiguration).ConfigureAwait(false); nextPageToken = existingParts.OpcNextPage; foreach (var part in existingParts.Items) { multipartManifest.RegisterExisting(part); } } while (nextPageToken != null); _multipartManifest = multipartManifest; _transferManager = new MultipartTransferManager(_multipartManifest, _service, _executorServiceToUse, _tokenSource.Token, _retryConfiguration); _initialized = true; return(multipartManifest); }