Class MultipartObjectAssembler
- java.lang.Object
-
- com.oracle.bmc.objectstorage.transfer.MultipartObjectAssembler
-
public class MultipartObjectAssembler extends Object
MultiPartObjectAssembler provides a simplified interaction with uploading large objects using multi-part uploads.An assembler can be used begin a new upload, or resume a previous one. Parts are be added to the assembler in order, and the assembler will handle all transfers and part numbering. Users can reference the returned manifest to watch/monitor updates to the upload as new parts are added or parts complete.
Note, a new assembler instance should be used for every multi-part upload. Once initialized (or resumed), an assembler cannot be reused.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MultipartObjectAssembler.MultipartObjectAssemblerBuilder
-
Constructor Summary
Constructors Constructor Description MultipartObjectAssembler(ObjectStorage service, String namespaceName, String bucketName, String objectName, boolean allowOverwrite, ExecutorService executorService)
Deprecated.usebuilder()
instead
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AbortMultipartUploadResponse
abort()
Aborts the current multi-part assembly and all uploads that are currently in progress.int
addPart(File file, String md5)
Add the next part to the upload.int
addPart(InputStream stream, long contentLength, String md5)
Add the next part to the upload.int
addPart(InputStream stream, long contentLength, String checksum, String checksumAlgorithm)
Adds the next part to the upload.static MultipartObjectAssembler.MultipartObjectAssemblerBuilder
builder()
CommitMultipartUploadResponse
commit()
Commits the multi-part upload after all in-progress uploads have completed.MultipartManifest
newRequest(String contentType, String contentLanguage, String contentEncoding, Map<String,String> opcMeta)
Initialize a new multi-part upload request.MultipartManifest
resumeRequest(String uploadId)
Resumes an existing multi-part upload using the upload ID.void
setOpcClientRequestId(String opcClientRequestId)
The opcClientRequestId to send for all requests related to this multi-part upload.void
setPart(File file, String md5, int partNum)
Adds a part to the upload.void
setPart(InputStream stream, long contentLength, String md5, int partNum)
Adds a part to the upload.void
setPart(InputStream stream, long contentLength, String checksum, String checksumAlgorithm, int partNum)
Adds a part to the upload.
-
-
-
Constructor Detail
-
MultipartObjectAssembler
@Deprecated public MultipartObjectAssembler(ObjectStorage service, String namespaceName, String bucketName, String objectName, boolean allowOverwrite, ExecutorService executorService)
Deprecated.usebuilder()
insteadCreates a new assembler.- Parameters:
service
- The object storage servicenamespaceName
- The namespace to usebucketName
- The bucket to useobjectName
- The final object name.allowOverwrite
- Allow uploads to overwrite existing parts with the same part numberexecutorService
- The executor service to use
-
-
Method Detail
-
newRequest
public MultipartManifest newRequest(String contentType, String contentLanguage, String contentEncoding, Map<String,String> opcMeta)
Initialize a new multi-part upload request.- Parameters:
contentType
- The content-type of the object, optionalcontentLanguage
- The content-language of the object, optionalcontentEncoding
- The content-encoding of the object, optional- Returns:
- A new manifest instance representing the object and it’s progress.
-
resumeRequest
public MultipartManifest resumeRequest(String uploadId)
Resumes an existing multi-part upload using the upload ID.- Parameters:
uploadId
- The upload ID.- Returns:
- A new manifest instance representing the object and it’s progress.
-
addPart
public int addPart(File file, String md5)
Add the next part to the upload.Parts will be committed in the order submitted.
Calling this will set the ifNoneMatch value and will not allow overwriting existing parts.
- Parameters:
file
- The file to upload as the next partmd5
- The MD5 checksum of the file, optional- Returns:
- The part number assigned to this part
-
addPart
public int addPart(InputStream stream, long contentLength, String md5)
Add the next part to the upload.Parts will be committed in the order submitted.
We allow part overwrites to facilitate retries.
- Parameters:
stream
- The stream to upload as the next partcontentLength
- The content length of the partmd5
- The MD5 checksum, optional- Returns:
- The part number assigned to this part
-
addPart
public int addPart(InputStream stream, long contentLength, String checksum, String checksumAlgorithm)
Adds the next part to the upload.Parts will be committed in the order submitted.
We allow part overwrites to facilitate retries.
- Parameters:
stream
- The stream to upload as the next partcontentLength
- The content length of the partchecksum
- The checksum of the part, optionalchecksumAlgorithm
- The checksum algorithm used, optional (e.g., “CRC32C”)- Returns:
- The part number assigned to this part
- Throws:
IllegalStateException
- if the assembler has not been initialized or the upload has been aborted
-
setPart
public void setPart(File file, String md5, int partNum)
Adds a part to the upload.The part will be ordered based on the part number provided.
This is useful to retry a failed part, to explicitly control the part numbering, or overwrite an existing part.
Calling this will not set the ifNoneMatch value and will allow overwriting existing parts.
- Parameters:
file
- The file to uploadmd5
- The MD5 checksum, optionalpartNum
- The part number to to assign to the part
-
setPart
public void setPart(InputStream stream, long contentLength, String md5, int partNum)
Adds a part to the upload.The part will be ordered based on the part number provided.
This is useful to retry a failed part, to explicitly control the part numbering, or overwrite an existing part.
Calling this will not set the ifNoneMatch value and will allow overwriting existing parts.
- Parameters:
stream
- The stream to uploadcontentLength
- The content length of the partmd5
- The MD5 checksum, optionalpartNum
- The part number to to assign to the part
-
setPart
public void setPart(InputStream stream, long contentLength, String checksum, String checksumAlgorithm, int partNum)
Adds a part to the upload.The part will be ordered based on the part number provided.
This method is for setting parts with additional checksum algorithms.
Calling this will not set the ifNoneMatch value and will allow overwriting existing parts.
- Parameters:
stream
- The stream to uploadcontentLength
- The content length of the partchecksum
- The checksum value, optionalchecksumAlgorithm
- The checksum algorithm usedpartNum
- The part number to assign to the part
-
abort
public AbortMultipartUploadResponse abort()
Aborts the current multi-part assembly and all uploads that are currently in progress.- Returns:
- abort response
-
commit
public CommitMultipartUploadResponse commit()
Commits the multi-part upload after all in-progress uploads have completed.This is a blocking call, and throws IllegalStateException if you try to commit an upload in which the Manifest reports it is not successful (
MultipartManifest.isUploadSuccessful()
).- Returns:
- The commit response.
-
builder
public static MultipartObjectAssembler.MultipartObjectAssemblerBuilder builder()
-
setOpcClientRequestId
public void setOpcClientRequestId(String opcClientRequestId)
The opcClientRequestId to send for all requests related to this multi-part upload.
-
-