Class MultipartUtils
- java.lang.Object
-
- com.oracle.bmc.objectstorage.transfer.internal.MultipartUtils
-
public final class MultipartUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static long
MiB
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
calculatePartSize(UploadConfiguration config, long contentLength)
Calculate the part size, in bytes, that should be used per multi-part upload part.static boolean
shouldCalculateAdditionalChecksum(UploadConfiguration config, PutObjectRequest request)
Test whether or not the additional checksum value should be calculated for the given request when issuing a single upload (non-multipart) request.static boolean
shouldCalculateMd5(UploadConfiguration config, PutObjectRequest request)
Test whether or not the MD5 value should be calculated for the given request when issuing a single upload (non-multipart) request.static boolean
shouldSetAdditionalChecksum(UploadConfiguration config, PutObjectRequest request)
Determines whether an additional checksum value should be set for the given request.static boolean
shouldUseMultipart(UploadConfiguration config, long contentLength)
Test whether an object of a given size is large enough to warrant using multi-part uploads.
-
-
-
Field Detail
-
MiB
public static final long MiB
- See Also:
- Constant Field Values
-
-
Method Detail
-
shouldUseMultipart
public static boolean shouldUseMultipart(@Nonnull UploadConfiguration config, long contentLength)
Test whether an object of a given size is large enough to warrant using multi-part uploads.- Parameters:
config
- The configuration to use.contentLength
- The length of the object in bytes.- Returns:
- true if multi-part uploads should be used, false if not.
-
calculatePartSize
public static long calculatePartSize(@Nonnull UploadConfiguration config, long contentLength)
Calculate the part size, in bytes, that should be used per multi-part upload part.- Parameters:
config
- The configuration to use.contentLength
- The length of the object in bytes.- Returns:
- The part size to use.
-
shouldCalculateMd5
public static boolean shouldCalculateMd5(@Nonnull UploadConfiguration config, @Nonnull PutObjectRequest request)
Test whether or not the MD5 value should be calculated for the given request when issuing a single upload (non-multipart) request.- Parameters:
config
- The configuration to use.request
- The request being sent.- Returns:
- true to calculate MD5, false if it’s not necessary.
-
shouldCalculateAdditionalChecksum
public static boolean shouldCalculateAdditionalChecksum(@Nonnull UploadConfiguration config, @Nonnull PutObjectRequest request)
Test whether or not the additional checksum value should be calculated for the given request when issuing a single upload (non-multipart) request.- Parameters:
config
- The configuration to use.request
- The request being sent.- Returns:
- true to calculate additional checksum, false if it’s not necessary.
-
shouldSetAdditionalChecksum
public static boolean shouldSetAdditionalChecksum(@Nonnull UploadConfiguration config, @Nonnull PutObjectRequest request)
Determines whether an additional checksum value should be set for the given request.This method covers the following cases:
- If the request already has a checksum algorithm set, the method returns false, as there's no need to set it again.
- If both the configuration's additional checksum algorithm and the request's checksum algorithm are provided but differ, an IllegalArgumentException is thrown.
- If the configuration has no additional checksum algorithm and the request has no checksum algorithm, the method returns false, as there's nothing to set.
- If the configuration has an additional checksum algorithm, and the request has no checksum algorithm, the method returns true, indicating that the additional checksum should be set.
- Parameters:
config
- The configuration to use.request
- The request being sent.- Returns:
- true if the additional checksum should be set, false otherwise.
- Throws:
NullPointerException
- if config or request is null.IllegalArgumentException
- if both the configuration and the request have different checksum algorithms.
-
-