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:
铲斗= MY-flologic桶, Endpoint = my-flologic-bucket.s3-us-west-2.amazonaws.com,Message = The 你试图访问的存储桶必须使用 指定的端点。请将以后的所有请求发送到此端点。 Code = PermanentRedirect,RequestId = E7471ACE4D6049F8}
答案 0 :(得分:1)
根据来自AWS Regions and Endpoints的区域和端点文档,以下区域端点对S3 us-west-2有效:
您可以尝试使用https://<bucket-name>.s3.us-west-2.amazonaws.com
代替s3-us-west-2.amazonaws.com。我知道s3-us-west-2.amazonaws.com也有效,但我总是使用前一个没有任何问题。