AWSStaticCredentialsProvider *credentialsProvider = [[AWSStaticCredentialsProvider alloc] initWithAccessKey:@"AKIA..........." secretKey:@"6FuqRt................."];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionEUWest2 credentialsProvider:credentialsProvider];
[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;
self.transferManager = [AWSS3TransferManager defaultS3TransferManager];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"qr" ofType:@"jpeg"];
AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new];
uploadRequest.bucket = @"my-flologic-bucket";
uploadRequest.key = @"monday.jpeg";
uploadRequest.body = [NSURL fileURLWithPath:filePath];
[[self.transferManager upload:uploadRequest] continueWithExecutor:[AWSExecutor mainThreadExecutor] withBlock:^id(AWSTask *task)
{
if (task.error)
{
NSLog(@"Error: %@", task.error);
}
else {
NSLog(@"The file uploaded successfully.");
}
return nil;
}];
ERROR:
Bucket=my-flologic-bucket, Endpoint=my-flologic-bucket.s3-us-west-2.amazonaws.com, Message=The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint., Code=PermanentRedirect, RequestId=E7471ACE4D6049F8}
As per the regions and endpoints document from AWS Regions and Endpoints, below region endpoints are valid for S3 us-west-2:
Can you try using https://<bucket-name>.s3.us-west-2.amazonaws.com
instead of s3-us-west-2.amazonaws.com. I understand s3-us-west-2.amazonaws.com is also valid, but I've always used the previous one without any issues.