4

I've been looking around and found no recent answer for a problem I'm having in uploading and downloading images from an iPhone application.

I'm using AWS SDK v2 and from what I have read and seen from sample S3 transfer codes, I need to start first using AWSCognitoCredentialsProvider.

AWSCognitoCredentialsProvider *credentialsProvider = [AWSCognitoCredentialsProvider
                                                          credentialsWithRegionType:AWSRegionAPNortheast1
                                                          accountId:AWSAccountID
                                                          identityPoolId:CognitoPoolID
                                                          unauthRoleArn:CognitoRoleUnauth
                                                      authRoleArn:nil];

But the only information I have are: Access Key, Secret, Bucket name, and target directory

Related link I read is How do I download a file from S3 to an iPhone application?

But the code cannot compile even with the AWS SDK framework, and related frameworks are installed in the project.

How can this be done using only the AWS SDK v2?

Thank you.

3 Answers 3

14

You can also scrap using Cognito and use the Access Key/Secret:

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

[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;

Make sure you use the region your bucket is actually in.

Sign up to request clarification or add additional context in comments.

2 Comments

those methods look deprecated
Amazon doesn't recommend them for production but instead pushes one to AWSCognito docs.aws.amazon.com/AWSiOSSDK/latest/Classes/…
8

For your convenience, I left the version in Swift

let credentialsProvider = AWSStaticCredentialsProvider(accessKey:"YOUR_ACCESS_KEY", secretKey: "YOUR_SECRET_KEY")
let defaultServiceConfiguration = AWSServiceConfiguration(region: AWSRegionType.EUWest1, credentialsProvider: credentialsProvider)
defaultServiceConfiguration.maxRetryCount = 5
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = defaultServiceConfiguration
let defaultS3 = AWSS3.defaultS3()

......

Comments

2

I recommend you follow the README and run the S3TransferManager sample app. In the Amazon Cognito console, you can get the information you need to instantiate the credentials provider.

Also, currently Amazon Cognito Identity is available in AWSRegionUSEast1 only.

3 Comments

Thank you for your reply. I'll check that link. And if its only available at AWSRegionUSEast1 only, maybe we'll try to use the REST API.
Amazon Cognito is only available in AWSRegionUSEast1, but Amazon S3 is available in many regions. The regions of these two services don't have to be the same.
Now US East (N. Virginia), EU (Ireland), and Asia Pacific (Tokyo) regions aws.amazon.com/about-aws/whats-new/2015/09/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.