I am developing an iOS app using AWS as its backend. Since I expect users to be world wide, I need to switch where the app should download photos in order to increase latenc
Was having the same issue just recently. The AWS SDK Docs are terribly confusing and contradicting, they suck...
The answer above pointed me in the right direction since I'm using developer authenticated identities, I am using the custom identity provider (same one that's in the sample docs on github). I used registerS3TransferManagerWithConfiguration
with the my credentials provider but then supplied AWSRegionUSWest2
as the region for key USWest2S3TransferManager
.
I then called AWSS3TransferManager *transferManager = [AWSS3TransferManager S3TransferManagerForKey:@"USWest2S3TransferManager"];
in my upload class.
Hopefully this helps someone else that's having similar issues.
- (AWSTask *)initializeClients:(NSDictionary *)logins {
NSLog(@"initializing clients...");
[AWSLogger defaultLogger].logLevel = AWSLogLevelVerbose;
id identityProvider = [[DeveloperAuthenticatedIdentityProvider alloc] initWithRegionType:AWSRegionUSEast1
identityId:nil
identityPoolId:identityPoolID
logins:logins
providerName:DeveloperAuthProviderName
authClient:nil];
self.credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
identityProvider:identityProvider
unauthRoleArn:nil
authRoleArn:nil];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:self.credentialsProvider];
[AWSS3TransferManager registerS3TransferManagerWithConfiguration:[[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2 credentialsProvider:self.credentialsProvider] forKey:@"USWest2S3TransferManager"];
AWSServiceManager.defaultServiceManager.defaultServiceConfiguration = configuration;
return [self.credentialsProvider getIdentityId];
}
my specific upload method:
- (void)performS3UploadWithRequest:(AWSS3TransferManagerUploadRequest *)request
{
AWSS3TransferManager *transferManager = [AWSS3TransferManager S3TransferManagerForKey:@"USWest2S3TransferManager"];
AWSTask *task = [AWSTask taskWithResult:nil];
__weak typeof(self) weakSelf = self;
task = [task continueWithSuccessBlock:^id(AWSTask *task) {
return [[transferManager upload:request] continueWithBlock:^id(AWSTask *task) {
if (task.error) {
[self handleErrorWithTask:task request:request];
}
if (task.result) {
AWSS3TransferManagerUploadOutput *uploadOutput = task.result;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf uploadProgress];
});
// The file uploaded successfully.
DLog(@"%@", uploadOutput);
}
return nil;
}];
}];
[task continueWithSuccessBlock:^id(AWSTask *task) {
return nil;
}];
}