我有一个较旧的应用程序,图像上传已经开始失败,代码在下面使用它:
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSError * __block anError = nil;
AWSS3PutObjectRequest *por = [AWSS3PutObjectRequest new];
por.key = key;
por.bucket = bucket;
por.contentType = @"image/png";
por.contentLength = [NSNumber numberWithUnsignedLong:[UIImagePNGRepresentation(image) length]];
por.body = UIImagePNGRepresentation(image);
por.ACL = AWSS3ObjectCannedACLPublicRead;
[[AWSS3 defaultS3] putObject:por completionHandler:^(AWSS3PutObjectOutput * _Nullable response, NSError * _Nullable error) {
anError = error;
dispatch_semaphore_signal(sema);
}];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
if (anError) {
NSException *exception = [NSException exceptionWithName:@"NoahPutObjectException" reason:[anError description] userInfo:nil];
@throw exception;
}
我可以确认存储桶没有更改并且位于正确的区域。我收到的错误是:
Error Domain=com.amazonaws.AWSS3ErrorDomain Code=0 "(null)" UserIn
fo={RequestId=F5B5BFDB18414371,
Bucket=BUCKETREDACTED, HostId=HOSTIDREDACTED,
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,
Endpoint=s3.amazonaws.com}
我已更新为使用最新的广告连播,但仍会收到此错误。
答案 0 :(得分:0)
在我看来,你正在使用" s3.amazonaws.com"作为您的终端,您需要使用特定于区域的端点地址,例如" s3-us-west-1.amazonaws.com"。按地区细分的正确端点网址可在此处找到:http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region