Aws-sdk-ios: AWSS3TransferUtility - Resuming uploads is not working with Network reachability

Created on 7 Oct 2016  Â·  22Comments  Â·  Source: aws-amplify/aws-sdk-ios

Uploads progress gets stop when Network drops and the progress automatically gets zero when the network becomes reachable. It is not getting resume. Can anyone help me on this, it is very urgent for me.

feature request requesting info s3

All 22 comments

this seems related to #487 can you confirm?

@karthiksaligrama Any update on this?

Hello @pratibha-bhandari

I am trying to reproduce this issue on our side. In the meanwhile, could you please provide some more details like:

-AWS iOS SDK version in use
-iOS version in use
-iPhone / iPad physical device version

Thanks,
Rohan

Hi @pratibha-bhandari

I was not able to re-produce this issue on my device using iOS 10.2 and Xcode 8.2.1. Could you please provide me with details requested above and also any code snippet which we could use to re-produce the issue?

Thanks,
Rohan

Hi,

I'm on version 10.1.1, and Xcode 8.1. I'm seeing the same issue. In the middle of an upload, I would turn off wifi and, after turning it back on, the upload progress starts from zero again.

Here's how I setup the completion and progress handlers in viewDidLoad:

` self.unassociatedStreamEndOverlay.uploadProgress.progress = 0;
self.completionHandler = ^(AWSS3TransferUtilityUploadTask *task, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (error) {
} else {
weakSelf.unassociatedStreamEndOverlay.uploadProgress.progress = 1.0;
}
});
};

self.progressBlock = ^(AWSS3TransferUtilityTask *task, NSProgress *progress) {
    dispatch_async(dispatch_get_main_queue(), ^{
        weakSelf.unassociatedStreamEndOverlay.uploadProgress.progress = progress.fractionCompleted;
    });
};

AWSS3TransferUtility *transferUtility = [AWSS3TransferUtility defaultS3TransferUtility];

[transferUtility enumerateToAssignBlocksForUploadTask:^(AWSS3TransferUtilityUploadTask * _Nonnull uploadTask, AWSS3TransferUtilityProgressBlock  _Nullable __autoreleasing * _Nullable uploadProgressBlockReference, AWSS3TransferUtilityUploadCompletionHandlerBlock  _Nullable __autoreleasing * _Nullable completionHandlerReference) {
    NSLog(@"%lu", (unsigned long)uploadTask.taskIdentifier);

    *uploadProgressBlockReference = weakSelf.progressBlock;
    *completionHandlerReference = weakSelf.completionHandler;

    dispatch_async(dispatch_get_main_queue(), ^{
    });
} downloadTask:nil];

`

Here's where I actually initiate the upload:

`NSURL *streamURL = [NSURL fileURLWithPath:self.localFileNames[0]];
AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc]
initWithRegionType:AWSRegionUSEast1

                                                              identityPoolId:@"MY IDENTITY POOL ID"];
        AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:credentialsProvider];
        configuration.allowsCellularAccess = NO;
        [AWSS3TransferUtility registerS3TransferUtilityWithConfiguration:configuration forKey:@"noCellularAccess"];
        AWSS3TransferUtilityUploadExpression *expression = [AWSS3TransferUtilityUploadExpression new];
        expression.progressBlock = self.progressBlock;

        AWSS3TransferUtility *transferUtility = [AWSS3TransferUtility S3TransferUtilityForKey:@"noCellularAccess"];
        [[transferUtility uploadFile:streamURL 
                              bucket:MY BUCKET
                                 key:@"SREEENDAWWGGG.mp4"
                         contentType:@"video/mp4"
                          expression:expression
                    completionHander:self.completionHandler] continueWithBlock:^id(AWSTask *task) {
            if (task.error) {
                NSLog(@"Error: %@", task.error);
            }
            if (task.exception) {
                NSLog(@"Exception: %@", task.exception);
            }
            if (task.result) {
                AWSS3TransferUtilityUploadTask *uploadTask = task.result;
                // Do something with uploadTask.
            }

            return nil;
        }];

`

@Sreeni34 Did you get any solution?

Hi ,

i am using

-AWS iOS SDK version 2.5.0
-iOS version in use is 10.2.1
-iPhone / iPad physical device version
-Xcode is 8.2.1

In my case also upload progress gets stop when Network drops and the progress automatically gets zero when the network becomes reachable. It is not getting resuming it starts again .

Please help me with this .

Thanks in advance

Thank you for providing us with the required data. Currently, AWSS3TransferUtility does not support multi-part upload download, thus preventing resuming from an interrupted upload or download due to network reachability conditions. The progress of upload or download is controlled by the operating system library which means the entire progress is lost if the upload or download task fails. Instead, you can use AWSS3TransferManager to support multi-part upload download. But, AWSS3TransferManager does not support background upload download. If you need background upload download, then AWSS3TransferUtility is the only choice as of now. We are taking this as a feature request.

same issue for my project, after change wifi to cell network then resume is not working at all !

@kvasukib Any idea when this feature might be added to the SDK? It looks like other SDKs (.NET, Android) support this functionality.

Is this something you would consider a pull request for?

Thanks,
Dave

@kvasukib Is there documentation on how to pause/resume multipart download upload with TransferManager when network is lost? "Out-of-the-box" it does not seem to handle a network loss like TransferUtility does (I just get 1009 errors when network is lost) so I assume I have to do that myself but some examples would be helpful.

Edit: I meant to say upload, not download.

Thanks, yes, sorry I meant to say Upload, not Download.

On Wed, Nov 22, 2017 at 3:24 PM, Karthikeyan notifications@github.com
wrote:

Multipart is supported only with Upload and not with the download. The
download function is always single-part. You can refer TransferManager
documentation
http://docs.aws.amazon.com/mobile/sdkforios/developerguide/s3transfermanager.html
here.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/aws/aws-sdk-ios/issues/489#issuecomment-346499432,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAMaGXLpCVFil_pz892PrfyoDUTVlUSFks5s5K0WgaJpZM4KQq97
.

@kvasukib could you answer pls? :)

Hi @jeffjvick and @chrisscholly, As we described above, the AWSSS3TransferManager supports multi-part upload but not background transfer wheres AWSS3TransferUtility supports background transfers, managing network loss, etc. but not multi-part upload. We acknowledge the fact that this is a feature gap and we will update here once we release it. Thanks for the understanding.

For monitoring network loss, you could use Reachability.swift library to know when the network is lost and pause the transfer.

@kvasukib I had ended up using https://github.com/ashleymills/Reachability.swift (what you said) to detect network loss and pause the AWSS3TransferManagerUploadRequest (although it didn't seem to matter if I paused it or not). Unlike TransferUtility though it does not resume on it's own when network returns and I finally figured out that I had to call AWSS3TransferManager.default().upload again on the paused request to get it to resume once I detected the network was back with Reachability. This was not documented nor intuitive.

Hi @jeffjvick, Sorry for the inconvenience caused. Thanks for confirming.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@jeffjvick can I ask you for code sample with AWSS3TransferManagerUploadRequest and Reachability.swift?

Hello all, We have added support for multi-part uploads in AWSS3TransferUtility in 2.6.13. Please upgrade to the latest and let us know any feedback you have.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Hello all,

The latest version of the SDK (2.6.23) has support for resuming transfers after app restart. 3 convenience methods have been added to the TransferUtilityTask

  • status: to get the current status of the transfer. Returns an enumeration of type AWSS3TransferUtilityTransferStatusType
  • setCompletionHandler: to set a completion handler to the transfer
  • setProgressBlock: to set a progress block to the transfer for tracking.

Please try these out and let me know if you run into issues.

Closing this issue as I haven't heard back. Also, we are tracking all TransferUtility pause/resume question is #769. Please feel free to reopen if you see fit.

Was this page helpful?
0 / 5 - 0 ratings