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

NSURLSession background upload support for s3 #25

Closed
rahulgautam opened this Issue Jul 22, 2014 · 42 comments

Comments

Projects
None yet
@rahulgautam

rahulgautam commented Jul 22, 2014

Hi I want to confirm that does aws-sdk-v2 supports background upload for files on amazon s3.
Because I see that's a very basic requirement as users won't stay in app until a long download finished.

If its not there please let me know how I could achive this, still using this SDK.
I'll be happy to contribute.

btw: Implemention with NSURLSession looks really nice. Thanks

@yosuke-matsuda

This comment has been minimized.

Show comment
Hide comment
@yosuke-matsuda

yosuke-matsuda Jul 22, 2014

Contributor

The SDK currently does not support background transfer. Due to how NSURLSession exposes the feature, there are a few issues we need to resolve:

  1. Because you can not persist blocks, we cannot reconstruct the serializer and interceptors when the app is restarted.
  2. NSURLSession requires you to implement some delegate methods. Wrapping these around in a clean interface can be challenging.

We are evaluating how we can provide background transfer. We'll update the thread when we add this feature in the SDK.

Thanks,

Contributor

yosuke-matsuda commented Jul 22, 2014

The SDK currently does not support background transfer. Due to how NSURLSession exposes the feature, there are a few issues we need to resolve:

  1. Because you can not persist blocks, we cannot reconstruct the serializer and interceptors when the app is restarted.
  2. NSURLSession requires you to implement some delegate methods. Wrapping these around in a clean interface can be challenging.

We are evaluating how we can provide background transfer. We'll update the thread when we add this feature in the SDK.

Thanks,

@rromanchuk

This comment has been minimized.

Show comment
Hide comment
@rromanchuk

rromanchuk Aug 11, 2014

hey @yosuke-matsuda i have some quick questions, have not had much time to browse the v2 code. I'm debating on weather or not to upgrade but this version. I'm a little concerned because this library doesn't seem to play well with NSURLSession which is concerning because that is the direction ios has been moving towards since ios7.

Currently i'm using a combination of AmazonS3Client and S3PutObjectRequest to sign a request then transferring headers back to a NSMutableURLRequest and then finally into a NSURLSessionUploadTask

At this point i see very little reason to even use the library, and i'm confused why BFTask was chosen over NSURLSessionTask as ios has been pushing so hard on it. I have yet to look through the header files yet, but is there any convenience methods that will simply help me setup and sign a NSMutableURLRequest?

rromanchuk commented Aug 11, 2014

hey @yosuke-matsuda i have some quick questions, have not had much time to browse the v2 code. I'm debating on weather or not to upgrade but this version. I'm a little concerned because this library doesn't seem to play well with NSURLSession which is concerning because that is the direction ios has been moving towards since ios7.

Currently i'm using a combination of AmazonS3Client and S3PutObjectRequest to sign a request then transferring headers back to a NSMutableURLRequest and then finally into a NSURLSessionUploadTask

At this point i see very little reason to even use the library, and i'm confused why BFTask was chosen over NSURLSessionTask as ios has been pushing so hard on it. I have yet to look through the header files yet, but is there any convenience methods that will simply help me setup and sign a NSMutableURLRequest?

@yosuke-matsuda

This comment has been minimized.

Show comment
Hide comment
@yosuke-matsuda

yosuke-matsuda Aug 11, 2014

Contributor

The SDK uses NSURLSession, and BFTask and NSURLSessionTask are totally different classes designed for very different purposes. Can you clarify what you mean by the SDK not play well with NSURLSession?

Contributor

yosuke-matsuda commented Aug 11, 2014

The SDK uses NSURLSession, and BFTask and NSURLSessionTask are totally different classes designed for very different purposes. Can you clarify what you mean by the SDK not play well with NSURLSession?

@rromanchuk

This comment has been minimized.

Show comment
Hide comment
@rromanchuk

rromanchuk Aug 11, 2014

Given an IAM access key, secret, and token, I'm looking for a very simple convenience method to create a NSMutableURLRequest to be used with NSURLSession in order to get the benefits of apple's background transfer service.

I have to hack my way through the aws clients just for the most basic requirement, i just want to setup a request object....It's also strange because apple's background transfer service and s3 uploading seem like the most obvious/natural use case. Just my opinion, but it feels like the transfer manager is trying to re-invent the wheel

rromanchuk commented Aug 11, 2014

Given an IAM access key, secret, and token, I'm looking for a very simple convenience method to create a NSMutableURLRequest to be used with NSURLSession in order to get the benefits of apple's background transfer service.

I have to hack my way through the aws clients just for the most basic requirement, i just want to setup a request object....It's also strange because apple's background transfer service and s3 uploading seem like the most obvious/natural use case. Just my opinion, but it feels like the transfer manager is trying to re-invent the wheel

@rromanchuk

This comment has been minimized.

Show comment
Hide comment
@rromanchuk

rromanchuk Aug 12, 2014

basically just looking for a cleaner implementation of this pretty common use case http://stackoverflow.com/questions/19478904/nsurlsession-and-amazon-s3-uploads/19698149#19698149 probably will just end up dropping the SDK and manually setting up the request

rromanchuk commented Aug 12, 2014

basically just looking for a cleaner implementation of this pretty common use case http://stackoverflow.com/questions/19478904/nsurlsession-and-amazon-s3-uploads/19698149#19698149 probably will just end up dropping the SDK and manually setting up the request

@renjithn

This comment has been minimized.

Show comment
Hide comment
@renjithn

renjithn Aug 12, 2014

rromanchuk.. Good that we are on the same page. Ive implemented this using the legacy put method in old versions- The issue i m facing now is the SSL errors popup for objects uploaded towards the end. Do you have any idea about this?

renjithn commented Aug 12, 2014

rromanchuk.. Good that we are on the same page. Ive implemented this using the legacy put method in old versions- The issue i m facing now is the SSL errors popup for objects uploaded towards the end. Do you have any idea about this?

@rromanchuk

This comment has been minimized.

Show comment
Hide comment
@rromanchuk

rromanchuk Aug 13, 2014

@renjithn make sure your access perms are ok putRequest.cannedACL = [S3CannedACL publicRead]

rromanchuk commented Aug 13, 2014

@renjithn make sure your access perms are ok putRequest.cannedACL = [S3CannedACL publicRead]

@axpence

This comment has been minimized.

Show comment
Hide comment
@axpence

axpence Aug 31, 2014

I would very much appreciate it if Amazon implemented this feature.

axpence commented Aug 31, 2014

I would very much appreciate it if Amazon implemented this feature.

@axpence

This comment has been minimized.

Show comment
Hide comment
@axpence

axpence Aug 31, 2014

@renjithn @rromanchuk is this the SSL error that you're referring to ?

Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo=0x1552f330 {NSErrorFailingURLStringKey=https://{my bucket name here}.s3-us-west-2.amazonaws.com/uID%3DFBE3AD1B-045E-4128-BD7A-D9F7BA18C22E%2Ccurrent_tape_index%3D0%2Casset_index%3D6%2Ctotal_assets%3D8%2Cfilename%3Dtape0IMG_2618.MOV, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSErrorFailingURLKey=https://{my bucket name here}.s3-us-west-2.amazonaws.com/uID%3DFBE3AD1B-045E-4128-BD7A-D9F7BA18C22E%2Ccurrent_tape_index%3D0%2Casset_index%3D6%2Ctotal_assets%3D8%2Cfilename%3Dtape0IMG_2618.MOV, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made.}

any pointers?

axpence commented Aug 31, 2014

@renjithn @rromanchuk is this the SSL error that you're referring to ?

Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo=0x1552f330 {NSErrorFailingURLStringKey=https://{my bucket name here}.s3-us-west-2.amazonaws.com/uID%3DFBE3AD1B-045E-4128-BD7A-D9F7BA18C22E%2Ccurrent_tape_index%3D0%2Casset_index%3D6%2Ctotal_assets%3D8%2Cfilename%3Dtape0IMG_2618.MOV, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSErrorFailingURLKey=https://{my bucket name here}.s3-us-west-2.amazonaws.com/uID%3DFBE3AD1B-045E-4128-BD7A-D9F7BA18C22E%2Ccurrent_tape_index%3D0%2Casset_index%3D6%2Ctotal_assets%3D8%2Cfilename%3Dtape0IMG_2618.MOV, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made.}

any pointers?

@renjithn

This comment has been minimized.

Show comment
Hide comment
@renjithn

renjithn Aug 31, 2014

@axpence Yes.. It happens with upload over HTTPs connection.

renjithn commented Aug 31, 2014

@axpence Yes.. It happens with upload over HTTPs connection.

@axpence

This comment has been minimized.

Show comment
Hide comment
@axpence

axpence Aug 31, 2014

@renjithn I did the following:

            s3.endpoint = [AmazonEndpoints s3Endpoint:US_WEST_2];
            NSLog(@"s3.endpont = %@",s3.endpoint);
            s3.endpoint = [s3.endpoint stringByReplacingOccurrencesOfString:@"https://" withString:@"http://"];
            NSLog(@"REPLACED s3.endpont = %@",s3.endpoint);

I'm sure that this is a tad insecure, however I am really looking for proof of concept here.

axpence commented Aug 31, 2014

@renjithn I did the following:

            s3.endpoint = [AmazonEndpoints s3Endpoint:US_WEST_2];
            NSLog(@"s3.endpont = %@",s3.endpoint);
            s3.endpoint = [s3.endpoint stringByReplacingOccurrencesOfString:@"https://" withString:@"http://"];
            NSLog(@"REPLACED s3.endpont = %@",s3.endpoint);

I'm sure that this is a tad insecure, however I am really looking for proof of concept here.

@renjithn

This comment has been minimized.

Show comment
Hide comment
@renjithn

renjithn Aug 31, 2014

I am not sure whether this qualifies as something to be discussed here- i.e this could well be an Apple bug with NSURLSession you know- what I've observed in my case here is that the didReceiveChallenge: callback of the NSURLSession(with backgroundSession configuration) gets triggered recursively after uploading a few files in the background and it seems like that the connection is broken ,upload fails and after I come back into the app and these SSL errors popup.

renjithn commented Aug 31, 2014

I am not sure whether this qualifies as something to be discussed here- i.e this could well be an Apple bug with NSURLSession you know- what I've observed in my case here is that the didReceiveChallenge: callback of the NSURLSession(with backgroundSession configuration) gets triggered recursively after uploading a few files in the background and it seems like that the connection is broken ,upload fails and after I come back into the app and these SSL errors popup.

@renjithn

This comment has been minimized.

Show comment
Hide comment
@renjithn

renjithn Aug 31, 2014

@axpence Is precisely what I did to get rid of these SSL errors.

renjithn commented Aug 31, 2014

@axpence Is precisely what I did to get rid of these SSL errors.

@axpence

This comment has been minimized.

Show comment
Hide comment
@axpence

axpence Aug 31, 2014

@renjithn did you ever get your upload errors to work? would you be willing to help me out offline? my email is in my profile.

axpence commented Aug 31, 2014

@renjithn did you ever get your upload errors to work? would you be willing to help me out offline? my email is in my profile.

@jterhorst

This comment has been minimized.

Show comment
Hide comment
@jterhorst

jterhorst Sep 4, 2014

@yosuke-matsuda I think what some of the others and myself would desire is a small, simple interface which just returns an NSURLRequest, and we can do the rest ourselves. I'm comfortable with NSURLSession and it's very easy for me to work with. All I want is a signed NSURLRequest for uploading to a specified key - NSURLSession will do the rest.

jterhorst commented Sep 4, 2014

@yosuke-matsuda I think what some of the others and myself would desire is a small, simple interface which just returns an NSURLRequest, and we can do the rest ourselves. I'm comfortable with NSURLSession and it's very easy for me to work with. All I want is a signed NSURLRequest for uploading to a specified key - NSURLSession will do the rest.

@rromanchuk

This comment has been minimized.

Show comment
Hide comment
@rromanchuk

rromanchuk Sep 4, 2014

@jterhorst yes yes yes 👍 This lib is trying to solve problems that shouldn't even be in its domain. Networking and thread management should not be the responsibility of this client. The designers are trying to compete with https://github.com/AFNetworking/AFNetworking which is insane. I'm glad there is a lib that "everyone can use" but for 80% of developers with production apps, i can't imagine them wanting anything more than a NSURLRequest

As mentioned before, the only way i know how to do this is with the old library, and even with that lib it was absolutely ridiculous.

S3PutObjectRequest *s3Request = [[S3PutObjectRequest alloc] initWithKey:key inBucket:_s3Bucket];
s3Request.cannedACL = [S3CannedACL publicReadWrite];
s3Request.securityToken = [CTUserDefaults awsS3SessionToken];
[s3Request configureURLRequest];
NSMutableURLRequest *request = [_s3Client signS3Request:s3Request];
// For some reason, the signed S3 request comes back with '(null)' as a host.
NSString *urlString = [NSString stringWithFormat:@"%@/%@/%@", _s3Client.endpoint, _s3Bucket, [key stringWithURLEncoding]] ;
request.URL = [NSURL URLWithString:urlString];
// Have to create a new request and copy all the headers otherwise the NSURLSessionDataTask will fail (since request get a pointer back to AmazonURLRequest which is a subclass of NSMutableURLRequest)
NSMutableURLRequest *request2 = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:urlString]];
[request2 setHTTPMethod:@"PUT"];
[request2 setAllHTTPHeaderFields:[request allHTTPHeaderFields]];

I think the community just needs to make a lightweight client that deals with the annoying parts of the s3 API, signing, setting headers, etc.

rromanchuk commented Sep 4, 2014

@jterhorst yes yes yes 👍 This lib is trying to solve problems that shouldn't even be in its domain. Networking and thread management should not be the responsibility of this client. The designers are trying to compete with https://github.com/AFNetworking/AFNetworking which is insane. I'm glad there is a lib that "everyone can use" but for 80% of developers with production apps, i can't imagine them wanting anything more than a NSURLRequest

As mentioned before, the only way i know how to do this is with the old library, and even with that lib it was absolutely ridiculous.

S3PutObjectRequest *s3Request = [[S3PutObjectRequest alloc] initWithKey:key inBucket:_s3Bucket];
s3Request.cannedACL = [S3CannedACL publicReadWrite];
s3Request.securityToken = [CTUserDefaults awsS3SessionToken];
[s3Request configureURLRequest];
NSMutableURLRequest *request = [_s3Client signS3Request:s3Request];
// For some reason, the signed S3 request comes back with '(null)' as a host.
NSString *urlString = [NSString stringWithFormat:@"%@/%@/%@", _s3Client.endpoint, _s3Bucket, [key stringWithURLEncoding]] ;
request.URL = [NSURL URLWithString:urlString];
// Have to create a new request and copy all the headers otherwise the NSURLSessionDataTask will fail (since request get a pointer back to AmazonURLRequest which is a subclass of NSMutableURLRequest)
NSMutableURLRequest *request2 = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:urlString]];
[request2 setHTTPMethod:@"PUT"];
[request2 setAllHTTPHeaderFields:[request allHTTPHeaderFields]];

I think the community just needs to make a lightweight client that deals with the annoying parts of the s3 API, signing, setting headers, etc.

@renjithn

This comment has been minimized.

Show comment
Hide comment
@renjithn

renjithn Sep 4, 2014

It seems as if the makers of SDK never expected something so powerful like NSURLSession coming - which can not only handle the upload/download but also gives one an option to calculate the progress and most importantly do all this stuff in the background- I feel for them actually - all the tough work with TM and now no one seems to be interested in using the latest version of SDK.

renjithn commented Sep 4, 2014

It seems as if the makers of SDK never expected something so powerful like NSURLSession coming - which can not only handle the upload/download but also gives one an option to calculate the progress and most importantly do all this stuff in the background- I feel for them actually - all the tough work with TM and now no one seems to be interested in using the latest version of SDK.

@rromanchuk

This comment has been minimized.

Show comment
Hide comment
@rromanchuk

rromanchuk Sep 4, 2014

@renjithn except AFNetworking with 215 contributors, 13.5k+ stars, and 3.5k forks has been around for a very long time. It's not just about NSURLSession...

rromanchuk commented Sep 4, 2014

@renjithn except AFNetworking with 215 contributors, 13.5k+ stars, and 3.5k forks has been around for a very long time. It's not just about NSURLSession...

@jterhorst

This comment has been minimized.

Show comment
Hide comment
@jterhorst

jterhorst Sep 4, 2014

Any of these other frameworks can take an NSURLRequest, and may or may not support new features faster, or be more reliable, than the AWS SDK. It just makes more sense to work that way, and not to reinvent the wheel.

jterhorst commented Sep 4, 2014

Any of these other frameworks can take an NSURLRequest, and may or may not support new features faster, or be more reliable, than the AWS SDK. It just makes more sense to work that way, and not to reinvent the wheel.

@yosuke-matsuda

This comment has been minimized.

Show comment
Hide comment
@yosuke-matsuda

yosuke-matsuda Sep 5, 2014

Contributor

We are working on the Presigned URL Builder for the v2 SDK, and it should cover your use case.

Contributor

yosuke-matsuda commented Sep 5, 2014

We are working on the Presigned URL Builder for the v2 SDK, and it should cover your use case.

@rromanchuk

This comment has been minimized.

Show comment
Hide comment
@rromanchuk

rromanchuk Sep 5, 2014

@yosuke-matsuda ❤️ love this, thanks!

rromanchuk commented Sep 5, 2014

@yosuke-matsuda ❤️ love this, thanks!

@yosuke-matsuda yosuke-matsuda removed the pending label Sep 16, 2014

@yosuke-matsuda

This comment has been minimized.

Show comment
Hide comment
@yosuke-matsuda

yosuke-matsuda Sep 16, 2014

Contributor

We've just released the AWS Mobile SDK for iOS 2.0.7, which contains AWSS3PreSignedURLBuilder. Thanks.

Contributor

yosuke-matsuda commented Sep 16, 2014

We've just released the AWS Mobile SDK for iOS 2.0.7, which contains AWSS3PreSignedURLBuilder. Thanks.

@axpence

This comment has been minimized.

Show comment
Hide comment
@axpence

axpence Sep 16, 2014

Do you have example code? @yosuke-matsuda ?

axpence commented Sep 16, 2014

Do you have example code? @yosuke-matsuda ?

@rahulgautam

This comment has been minimized.

Show comment
Hide comment
@rahulgautam

rahulgautam Sep 16, 2014

@yosuke-matsuda you closed the issue, means now from v2.0.7 there is NSURLSession background upload support. Just want to confirm.

Thanks

Hey @axpence for AWSS3PreSignedURLBuilder, have a look at the tests in SDK AWSS3PreSignedURLBuilderTests.m.

rahulgautam commented Sep 16, 2014

@yosuke-matsuda you closed the issue, means now from v2.0.7 there is NSURLSession background upload support. Just want to confirm.

Thanks

Hey @axpence for AWSS3PreSignedURLBuilder, have a look at the tests in SDK AWSS3PreSignedURLBuilderTests.m.

@rromanchuk

This comment has been minimized.

Show comment
Hide comment
@rromanchuk

rromanchuk Sep 16, 2014

Hmm, does anyone know if this supports "AWS Security Token Service" which signs requests with key, secret, and security token. http://docs.aws.amazon.com/AmazonS3/latest/dev/AuthUsingTempSessionToken.html

rromanchuk commented Sep 16, 2014

Hmm, does anyone know if this supports "AWS Security Token Service" which signs requests with key, secret, and security token. http://docs.aws.amazon.com/AmazonS3/latest/dev/AuthUsingTempSessionToken.html

@Ganidu

This comment has been minimized.

Show comment
Hide comment
@Ganidu

Ganidu Sep 23, 2014

Hey ,Seems i just fall into same page.. Does the amazon V2 supports background uploads with AWSS3PreSignedURLBuilder?? coz i already i tried uploading larger videos with V1 , and sometimes it doesn't work , i tried to resume with V1 if connection drops but it didn't work . does it supports in V2

Ganidu commented Sep 23, 2014

Hey ,Seems i just fall into same page.. Does the amazon V2 supports background uploads with AWSS3PreSignedURLBuilder?? coz i already i tried uploading larger videos with V1 , and sometimes it doesn't work , i tried to resume with V1 if connection drops but it didn't work . does it supports in V2

@Ganidu

This comment has been minimized.

Show comment
Hide comment
@Ganidu

Ganidu Sep 24, 2014

I tied to implement with V2 api to have resume capability upon connection drops , but uploadTask gives me 0 , am i doing anything wrong here ??

AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithAccessKey:accessKey secretKey:secretKey];
AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSWest2 credentialsProvider:credentialsProvider];

[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;
AWSS3PreSignedURLBuilder * urlBuilder = [[AWSS3PreSignedURLBuilder alloc] initWithConfiguration:configuration];

AWSS3GetPreSignedURLRequest *req = [AWSS3GetPreSignedURLRequest new];
req.bucket = bucket;
req.key  = [url lastPathComponent];
req.httpMethod  = AWSHTTPMethodHEAD;
req.expires = [NSDate dateWithTimeIntervalSinceNow:(NSTimeInterval) 3600];

NSURL *preSignedURL = [urlBuilder getPreSignedURL:req];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:preSignedURL];
self.uploadTask = [[self backgroundURLSession] uploadTaskWithRequest:request fromFile:url];  
NSLog(@"uploadTask %lld",[_uploadTask countOfBytesExpectedToSend]);

Ganidu commented Sep 24, 2014

I tied to implement with V2 api to have resume capability upon connection drops , but uploadTask gives me 0 , am i doing anything wrong here ??

AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithAccessKey:accessKey secretKey:secretKey];
AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSWest2 credentialsProvider:credentialsProvider];

[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;
AWSS3PreSignedURLBuilder * urlBuilder = [[AWSS3PreSignedURLBuilder alloc] initWithConfiguration:configuration];

AWSS3GetPreSignedURLRequest *req = [AWSS3GetPreSignedURLRequest new];
req.bucket = bucket;
req.key  = [url lastPathComponent];
req.httpMethod  = AWSHTTPMethodHEAD;
req.expires = [NSDate dateWithTimeIntervalSinceNow:(NSTimeInterval) 3600];

NSURL *preSignedURL = [urlBuilder getPreSignedURL:req];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:preSignedURL];
self.uploadTask = [[self backgroundURLSession] uploadTaskWithRequest:request fromFile:url];  
NSLog(@"uploadTask %lld",[_uploadTask countOfBytesExpectedToSend]);
@cerupcat

This comment has been minimized.

Show comment
Hide comment
@cerupcat

cerupcat Dec 23, 2014

This issue has been closed, but has anyone actually defined a clear solution to doing upload in the background? Is there a complete example anywhere?

cerupcat commented Dec 23, 2014

This issue has been closed, but has anyone actually defined a clear solution to doing upload in the background? Is there a complete example anywhere?

@Ganidu

This comment has been minimized.

Show comment
Hide comment
@Ganidu

Ganidu Dec 24, 2014

Hey, I have developed a custom class using v1 sdk, it does not resume, but it works perfectly

Sent from my iPhone

On Dec 24, 2014, at 4:09 AM, Seth notifications@github.com wrote:

This issue has been closed, but has anyone actually defined a clear solution to doing upload in the background? Is there a complete example anywhere?


Reply to this email directly or view it on GitHub.

Ganidu commented Dec 24, 2014

Hey, I have developed a custom class using v1 sdk, it does not resume, but it works perfectly

Sent from my iPhone

On Dec 24, 2014, at 4:09 AM, Seth notifications@github.com wrote:

This issue has been closed, but has anyone actually defined a clear solution to doing upload in the background? Is there a complete example anywhere?


Reply to this email directly or view it on GitHub.

@renjithn

This comment has been minimized.

Show comment
Hide comment
@renjithn

renjithn Feb 6, 2015

@yosuke-matsuda Any update on this ? I do see a AWSURLSessionManager.m
Can you confirm this?

renjithn commented Feb 6, 2015

@yosuke-matsuda Any update on this ? I do see a AWSURLSessionManager.m
Can you confirm this?

@vbarshai

This comment has been minimized.

Show comment
Hide comment
@vbarshai

vbarshai Feb 9, 2015

Hi, required for me as well, please confirm that this is in v2 SDK (using pods)

vbarshai commented Feb 9, 2015

Hi, required for me as well, please confirm that this is in v2 SDK (using pods)

@rromanchuk

This comment has been minimized.

Show comment
Hide comment
@rromanchuk

rromanchuk Feb 9, 2015

@cerupcat i will make a simple end to end project for everyone. I struggled through this for a while because apple's background transfer service is complex enough as it is, and aws-sdk-ios doesn't really make it easier. As I mentioned before, this SDK is focused on the 1%, not developers who already know how to make a non-blocking network request.

rromanchuk commented Feb 9, 2015

@cerupcat i will make a simple end to end project for everyone. I struggled through this for a while because apple's background transfer service is complex enough as it is, and aws-sdk-ios doesn't really make it easier. As I mentioned before, this SDK is focused on the 1%, not developers who already know how to make a non-blocking network request.

@rromanchuk

This comment has been minimized.

Show comment
Hide comment
@rromanchuk

rromanchuk Feb 9, 2015

@yosuke-matsuda how do we set the ACL? I don't see any interface in the API

rromanchuk commented Feb 9, 2015

@yosuke-matsuda how do we set the ACL? I don't see any interface in the API

@yosuke-matsuda

This comment has been minimized.

Show comment
Hide comment
@yosuke-matsuda

yosuke-matsuda Feb 9, 2015

Contributor

Here are our current recommendations for using Amazon S3 with background transfer feature of the iOS.

AWSS3TransferManager is not designed to work in the background. Use AWSS3PreSignedURLBuilder to generate a pre-signed URL and upload/download data in the background with the native NSURLSession. Take a look at S3BackgroundTransfer Sample in our GitHub repo. Also, more configuration options for AWSS3PreSignedURLBuilder are on their way.

Contributor

yosuke-matsuda commented Feb 9, 2015

Here are our current recommendations for using Amazon S3 with background transfer feature of the iOS.

AWSS3TransferManager is not designed to work in the background. Use AWSS3PreSignedURLBuilder to generate a pre-signed URL and upload/download data in the background with the native NSURLSession. Take a look at S3BackgroundTransfer Sample in our GitHub repo. Also, more configuration options for AWSS3PreSignedURLBuilder are on their way.

@vbarshai

This comment has been minimized.

Show comment
Hide comment
@vbarshai

vbarshai Feb 9, 2015

Thank you @yosuke-matsuda ; Are there plans to update the design of AWSS3TransferManager such that it supports background upload? Just want to avoid performing a work-around if this is something that's in the pipeline in the coming period.

vbarshai commented Feb 9, 2015

Thank you @yosuke-matsuda ; Are there plans to update the design of AWSS3TransferManager such that it supports background upload? Just want to avoid performing a work-around if this is something that's in the pipeline in the coming period.

@yosuke-matsuda

This comment has been minimized.

Show comment
Hide comment
@yosuke-matsuda

yosuke-matsuda Feb 10, 2015

Contributor

Considering how the Foundation framework exposes background transfer APIs, currently it is quite challenging for us to provide an easy-to-use wrapper function as a part of AWSS3TrasnferManager. We may be able to provide some utility functions but are probably not able to drastically reduce the amount of glue code you have to write. This is the primary reason we decided to provide a sample app using AWSS3PreSignedURL with the native NSURLSession for background transfer instead of trying to integrate the feature directly into AWSS3TransferManager.

If you are looking for a nice wrapper for NSURLSession, AFNetworking provides some helpful utility functions for NSURLSession.

If you have ideas to enhance the background transfer integration, please share with us. We always appreciate ideas to improve our developer experience. Thanks!

Contributor

yosuke-matsuda commented Feb 10, 2015

Considering how the Foundation framework exposes background transfer APIs, currently it is quite challenging for us to provide an easy-to-use wrapper function as a part of AWSS3TrasnferManager. We may be able to provide some utility functions but are probably not able to drastically reduce the amount of glue code you have to write. This is the primary reason we decided to provide a sample app using AWSS3PreSignedURL with the native NSURLSession for background transfer instead of trying to integrate the feature directly into AWSS3TransferManager.

If you are looking for a nice wrapper for NSURLSession, AFNetworking provides some helpful utility functions for NSURLSession.

If you have ideas to enhance the background transfer integration, please share with us. We always appreciate ideas to improve our developer experience. Thanks!

@Ganidu

This comment has been minimized.

Show comment
Hide comment
@Ganidu

Ganidu Feb 24, 2015

@yosuke-matsuda

I managed to integrate V2 sdk with NSUrlSession this upload works fine but i sometimes it doesn't

1)Lets say if i uploded 4 video more than 500 MB then with the 5 th video it doesn't upload ,
2)application get stucked ,
3) Is there any way i can resume uploading

Ganidu commented Feb 24, 2015

@yosuke-matsuda

I managed to integrate V2 sdk with NSUrlSession this upload works fine but i sometimes it doesn't

1)Lets say if i uploded 4 video more than 500 MB then with the 5 th video it doesn't upload ,
2)application get stucked ,
3) Is there any way i can resume uploading

@hash3r

This comment has been minimized.

Show comment
Hide comment
@hash3r

hash3r Mar 4, 2015

@yosuke-matsuda how can we set the ACL to headers with presigned URL builder? May be you know some workaround without using putObjectAcl after uploading file

hash3r commented Mar 4, 2015

@yosuke-matsuda how can we set the ACL to headers with presigned URL builder? May be you know some workaround without using putObjectAcl after uploading file

@vbarshai

This comment has been minimized.

Show comment
Hide comment
@vbarshai

vbarshai Mar 12, 2015

Hi @yosuke-matsuda ; we've went ahead and used AWSS3PreSignedURLBuilder ; getPreSignedURL , but it from what I could tell it uses Version-2 Authentication??
i.e. we're trying to upload to the new Frankfurt bucket and so I suppose to use Version-4 I need to append @"x-amz-algorithm":@"AWS4-HMAC-SHA256" to the request:

AWSS3GetPreSignedURLRequest *getPreSignedURLRequest = [AWSS3GetPreSignedURLRequest new];
getPreSignedURLRequest.bucket = currentBucketName;
getPreSignedURLRequest.key = key;
getPreSignedURLRequest.HTTPMethod = AWSHTTPMethodPUT;
getPreSignedURLRequest.expires = [NSDate dateWithTimeIntervalSinceNow:3600];
//Important: must set contentType for PUT request
getPreSignedURLRequest.contentType = contentType;
getPreSignedURLRequest.additionalAmzHeaders = @{@"x-amz-acl":@"public-read",
                                                @"x-amz-algorithm":@"AWS4-HMAC-SHA256"};

then we use the following to get the URL:
[preSignedURLBuilder getPreSignedURL:getPreSignedURLRequest]

and further NSURLSessionUploadTask to upload. But it's not working. It responds as a success, the files aren't there though. Have you seen this before? Thank you in advance

vbarshai commented Mar 12, 2015

Hi @yosuke-matsuda ; we've went ahead and used AWSS3PreSignedURLBuilder ; getPreSignedURL , but it from what I could tell it uses Version-2 Authentication??
i.e. we're trying to upload to the new Frankfurt bucket and so I suppose to use Version-4 I need to append @"x-amz-algorithm":@"AWS4-HMAC-SHA256" to the request:

AWSS3GetPreSignedURLRequest *getPreSignedURLRequest = [AWSS3GetPreSignedURLRequest new];
getPreSignedURLRequest.bucket = currentBucketName;
getPreSignedURLRequest.key = key;
getPreSignedURLRequest.HTTPMethod = AWSHTTPMethodPUT;
getPreSignedURLRequest.expires = [NSDate dateWithTimeIntervalSinceNow:3600];
//Important: must set contentType for PUT request
getPreSignedURLRequest.contentType = contentType;
getPreSignedURLRequest.additionalAmzHeaders = @{@"x-amz-acl":@"public-read",
                                                @"x-amz-algorithm":@"AWS4-HMAC-SHA256"};

then we use the following to get the URL:
[preSignedURLBuilder getPreSignedURL:getPreSignedURLRequest]

and further NSURLSessionUploadTask to upload. But it's not working. It responds as a success, the files aren't there though. Have you seen this before? Thank you in advance

@yosuke-matsuda

This comment has been minimized.

Show comment
Hide comment
@yosuke-matsuda

yosuke-matsuda Mar 12, 2015

Contributor

AWSS3PreSignedURLBuilder currently supports only AWS Signature Version 2, meaning Frankfurt and Beijing regions are not supported. Could you create a new thread for SigV4 support in AWSS3PreSignedURLBuilder? We will follow up in that thread.

For other configuration options support including ACL is in our backlog, and we prioritize it accordingly.

Thanks,

Contributor

yosuke-matsuda commented Mar 12, 2015

AWSS3PreSignedURLBuilder currently supports only AWS Signature Version 2, meaning Frankfurt and Beijing regions are not supported. Could you create a new thread for SigV4 support in AWSS3PreSignedURLBuilder? We will follow up in that thread.

For other configuration options support including ACL is in our backlog, and we prioritize it accordingly.

Thanks,

@mcsio

This comment has been minimized.

Show comment
Hide comment
@mcsio

mcsio May 14, 2015

Any update on support for Version 4 signing?

mcsio commented May 14, 2015

Any update on support for Version 4 signing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment