Class MultipartUtils


  • public final class MultipartUtils
    extends Object
    • 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.