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.
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()
......
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With