Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(S3): implements suspend and resume features for multipart upload tasks #4168

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AWSS3/AWSS3TransferUtility+HeaderHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ - (void)assignRequestParameters:(AWSS3GetPreSignedURLRequest *)getPreSignedURLRe

@implementation AWSS3TransferUtility (HeaderHelper)

-(void) filterAndAssignHeaders:(NSDictionary<NSString *, NSString *> *) requestHeaders
- (void)filterAndAssignHeaders:(NSDictionary<NSString *, NSString *> *) requestHeaders
getPresignedURLRequest:(AWSS3GetPreSignedURLRequest *) getPresignedURLRequest
URLRequest: (NSMutableURLRequest *) URLRequest {

Expand Down
24 changes: 24 additions & 0 deletions AWSS3/AWSS3TransferUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,30 @@ handleEventsForBackgroundURLSession:(NSString *)identifier
expression:(nullable AWSS3TransferUtilityDownloadExpression *)expression
completionHandler:(nullable AWSS3TransferUtilityDownloadCompletionHandlerBlock)completionHandler;

///**
// Suspends multipart upload
// @param multipartUploadTask task
// */
//- (nullable NSError *)suspendMultipartUpload:(AWSS3TransferUtilityMultiPartUploadTask *)multipartUploadTask;

/**
Suspends all multipart uploads.
@param completionHandler completion handler
*/
- (void)suspendAllMultipartUploadsWithCompletionHandler:(nullable AWSS3TransferUtilityMultiPartUploadSuspendBlock)completionHandler;

///**
// Resumes a multipart upload.
// @param multiPartUploadTask The task to resume
// */
//- (nullable NSError *)resumeMultipartUpload:(nonnull AWSS3TransferUtilityMultiPartUploadTask *)multiPartUploadTask;

/**
Resumes all multipart uploads.
@param completionHandler completion handler
*/
- (void)resumeAllMultipartUploadsWithCompletionHandler:(nullable AWSS3TransferUtilityMultiPartUploadResumeBlock)completionHandler;

/**
Assigns progress feedback and completion handler blocks. This method should be called when the app was suspended while the transfer is still happening.

Expand Down
729 changes: 347 additions & 382 deletions AWSS3/AWSS3TransferUtility.m

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions AWSS3/AWSS3TransferUtilityDatabaseHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ + (void) updateTransferRequestInDB: (NSString *) transferID
status: (AWSS3TransferUtilityTransferStatusType) status
retry_count: (NSUInteger) retryCount
databaseQueue: (AWSFMDatabaseQueue *) databaseQueue {
if (eTag == nil) {
eTag = @"";
}
NSString *const AWSS3TransferUtilityUpdateTransferUtilityStatusAndETag = @"UPDATE awstransfer "
@"SET status=:status, etag = :etag, session_task_id = :session_task_id, retry_count = :retry_count "
@"WHERE transfer_id=:transfer_id and "
Expand Down
19 changes: 19 additions & 0 deletions AWSS3/AWSS3TransferUtilityTasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ typedef void (^AWSS3TransferUtilityMultiPartProgressBlock) (AWSS3TransferUtility
NSProgress *progress);


/**
The suspend multipart upload completion handler.

@param error Returns the error object when the suspending failed. Returns `nil` on success.
*/
typedef void (^AWSS3TransferUtilityMultiPartUploadSuspendBlock) (NSError * _Nullable error);

/**
The resume multipart upload completion handler.

@param error Returns the error object when the resume failed. Returns `nil` on success.
*/
typedef void (^AWSS3TransferUtilityMultiPartUploadResumeBlock) (NSError * _Nullable error);

#pragma mark - AWSS3TransferUtilityTasks

/**
Expand Down Expand Up @@ -140,6 +154,11 @@ typedef void (^AWSS3TransferUtilityMultiPartProgressBlock) (AWSS3TransferUtility
*/
@property (nullable, readonly) NSHTTPURLResponse *response;

/**
Error after operation.
*/
@property (nullable, readonly) NSError *error;

/**
Cancels the task.
*/
Expand Down
Loading