/** * Commits the multi-part upload after all in-progress uploads have * completed. * <p> * This is a blocking call, and throws IllegalStateException if you try to commit an upload * in which the Manifest reports it is not successful ({@link MultipartManifest#isUploadSuccessful}). * @return The commit response. */ public CommitMultipartUploadResponse commit() { validateState(); transferManager.awaitCompletion(); if (!manifest.isUploadSuccessful()) { throw new IllegalStateException( "One or more parts were have not completed upload successfully"); } return service.commitMultipartUpload( CommitMultipartUploadRequest.builder() .namespaceName(namespaceName) .bucketName(bucketName) .objectName(objectName) .uploadId(manifest.getUploadId()) .commitMultipartUploadDetails( CommitMultipartUploadDetails.builder() .partsToCommit(manifest.listCompletedParts()) .partsToExclude( new ArrayList<Integer>(0)) // nothing to exclude .build()) .opcClientRequestId(createClientRequestId("-commit")) .build()); }
/** * Copy method to populate the builder with values from the given instance. * @return this builder instance */ public Builder copy(CommitMultipartUploadRequest o) { namespaceName(o.getNamespaceName()); bucketName(o.getBucketName()); objectName(o.getObjectName()); uploadId(o.getUploadId()); commitMultipartUploadDetails(o.getCommitMultipartUploadDetails()); ifMatch(o.getIfMatch()); ifNoneMatch(o.getIfNoneMatch()); opcClientRequestId(o.getOpcClientRequestId()); invocationCallback(o.getInvocationCallback()); return this; }