Class MultipartDownloadUtils

java.lang.Object
software.amazon.awssdk.services.s3.internal.multipart.MultipartDownloadUtils

@SdkInternalApi public final class MultipartDownloadUtils extends Object
  • Method Details

    • completedParts

      public static List<Integer> completedParts(GetObjectRequest request)
      This method checks the S3MultipartExecutionAttribute.MULTIPART_DOWNLOAD_RESUME_CONTEXT execution attributes for a context object and returns the complete parts associated with it, or an empty list of no context is found.
      Parameters:
      request -
      Returns:
      The list of completed parts for a GetObjectRequest, or an empty list if none were found.
    • multipartDownloadResumeContext

      public static Optional<MultipartDownloadResumeContext> multipartDownloadResumeContext(GetObjectRequest request)
      This method checks the S3MultipartExecutionAttribute.MULTIPART_DOWNLOAD_RESUME_CONTEXT execution attributes for a context object and returns it if it finds one. Otherwise, returns an empty Optional.
      Parameters:
      request - the request to look for execution attributes
      Returns:
      the MultipartDownloadResumeContext if one is found, otherwise an empty Optional.
    • multipartDownloadResumeContext

      public static Optional<MultipartDownloadResumeContext> multipartDownloadResumeContext(S3Request request)
      This method checks the S3MultipartExecutionAttribute.MULTIPART_DOWNLOAD_RESUME_CONTEXT execution attributes for a context object and returns it if it finds one. Otherwise, returns an empty Optional.
      Parameters:
      request - the request to look for execution attributes
      Returns:
      the MultipartDownloadResumeContext if one is found, otherwise an empty Optional.
    • parseContentRange

      public static long[] parseContentRange(String contentRange)
      Parses start byte and end byte from a Content-Range header.
      Parameters:
      contentRange - the Content-Range header value (e.g., "bytes 0-1023/2048")
      Returns:
      array of [startByte, endByte], or null if parsing fails
    • parseContentRangeForTotalSize

      public static Optional<Long> parseContentRangeForTotalSize(String contentRange)
      Parses the total size from a Content-Range header.
      Parameters:
      contentRange - the Content-Range header value (e.g., "bytes 0-1023/2048")
      Returns:
      the total size, or empty if parsing fails
    • calculateTotalParts

      public static long calculateTotalParts(long contentLength, long partSize)
      Calculates the total number of parts needed to download an object of the given size.
      Parameters:
      contentLength - total object size in bytes
      partSize - size of each part in bytes
      Returns:
      the number of parts
    • toFullObjectResponse

      public static GetObjectResponse toFullObjectResponse(GetObjectResponse firstPartResponse)
      Rewrites a first-part response to represent the full object.
      Parameters:
      firstPartResponse - the GetObjectResponse from the first part request
      Returns:
      full-object response with total content-length, full content-range, and checksum values nulled if checksum type is COMPOSITE
    • splitWithResponseRewrite

      Splits the given transformer with a response mapper that applies toFullObjectResponse(software.amazon.awssdk.services.s3.model.GetObjectResponse) to the first part's response before it reaches the customer's transformer.