Class ResumableRequestConverter
java.lang.Object
software.amazon.awssdk.transfer.s3.internal.utils.ResumableRequestConverter
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanResumeDownload(ResumableFileDownload resumableFileDownload, HeadObjectResponse headObjectResponse) Determines whether a paused download can continue from where it left off, or whether it has to be restarted from the beginning because either the S3 object or the local file was modified while the download was paused.static DownloadFileRequesttoCrtDownloadFileRequest(ResumableFileDownload resumableFileDownload, HeadObjectResponse headObjectResponse, DownloadFileRequest originalDownloadRequest, boolean restartFromBeginning) Builds theDownloadFileRequestfor resuming a paused download that is being written to the destination file by CRT rather than by anAsyncResponseTransformer.toDownloadFileRequestAndTransformer(ResumableFileDownload resumableFileDownload, HeadObjectResponse headObjectResponse, DownloadFileRequest originalDownloadRequest)
-
Method Details
-
toDownloadFileRequestAndTransformer
public static Pair<DownloadFileRequest,AsyncResponseTransformer<GetObjectResponse, toDownloadFileRequestAndTransformerGetObjectResponse>> (ResumableFileDownload resumableFileDownload, HeadObjectResponse headObjectResponse, DownloadFileRequest originalDownloadRequest) Converts aResumableFileDownloadtoDownloadFileRequestandAsyncResponseTransformerpair.If before resuming the download the file on disk was modified, or the s3 object was modified, we need to restart the download from the beginning.
If the original requests has some individual parts downloaded, we need to make a multipart GET for the remaining parts.
Else, we need to make a ranged GET for the remaining bytes.
-
canResumeDownload
public static boolean canResumeDownload(ResumableFileDownload resumableFileDownload, HeadObjectResponse headObjectResponse) Determines whether a paused download can continue from where it left off, or whether it has to be restarted from the beginning because either the S3 object or the local file was modified while the download was paused. Logs the reason at debug level when a restart is required.- Returns:
- true if the remaining bytes can be fetched, false if the whole object must be downloaded again
-
toCrtDownloadFileRequest
public static DownloadFileRequest toCrtDownloadFileRequest(ResumableFileDownload resumableFileDownload, HeadObjectResponse headObjectResponse, DownloadFileRequest originalDownloadRequest, boolean restartFromBeginning) Builds theDownloadFileRequestfor resuming a paused download that is being written to the destination file by CRT rather than by anAsyncResponseTransformer. UnliketoDownloadFileRequestAndTransformer(ResumableFileDownload, HeadObjectResponse, DownloadFileRequest)there is no transformer to pair the request with, and no part-GET variant to consider, since the CRT-based client always downloads an object with a single meta request.- Parameters:
restartFromBeginning- whether the whole object should be downloaded again rather than only the remaining bytes
-