1
我有一箇舊的應用衛生組織圖像上載已經開始失敗,代碼中使用它下面:AWS Objective-C的圖像上載
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}
我已更新爲使用最新的吊艙,但仍然收到此錯誤。
我到底該如何設置?這是一箇舊的繼承代碼庫,所以我有點迷路了。 – steventnorris
呵呵,你已經對我有了一個感覺,能夠真正閱讀那個舊的代碼庫。我會先從:grep s3.amazonaws.com - 基本上你必須找到該URL是硬編碼還是保存在配置中並更改它。 – CodeWriter23
Gotcha。我看到了一些相關信息,但我認爲它只適用於我讀過的非美國桶。沒有意識到它也適用於美國。 – steventnorris