2016-12-29 9 views
1

Xcodeプロジェクトからs3バケットにイメージをアップロードしようとしていますが、初めて完全に動作しますが、1つのイメージをアップロードするとエラーが発生しますエラーs3 Bucketイメージアップロードの問題が発生しました(Objective C)

AWSiOSSDK v2.4.12 [エラー] AWSCredentialsProvider.m行:577 | __44- [AWSCognitoCredentialsProvider資格情報] _block_invoke.353 |リフレッシュできません。私はエラーがある[エラードメイン= com.amazonaws.AWSCognitoIdentityErrorDomainコード= 10 "(ヌル)" のUserInfo = {__タイプ= ResourceNotFoundException、メッセージ= IdentityPool '米国西部-2xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' が見つかりません。}]

とコード使用するには、あなたは私たち-東-1を見て資格情報プロバイダを言っているように見えます。この

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
// Override point for customization after application launch. 

AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] 
                 initWithRegionType:AWSRegionUSEast1 
                 identityPoolId:@"us-west-2xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]; 

AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:credentialsProvider]; 

[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; 
return YES;} 

-(void)uplaodImageToS3 :(NSString *)userId 
{ 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *path = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"user_%@.png", userId]]; 

    NSData *imageData = UIImagePNGRepresentation(uploadedImage); 
    [imageData writeToFile:path atomically:YES]; 

    NSURL *url = [[NSURL alloc] initFileURLWithPath:path]; 

    _uploadRequest = [AWSS3TransferManagerUploadRequest new]; 
    _uploadRequest.bucket = @"dellonybucket"; 
    _uploadRequest.ACL = AWSS3ObjectCannedACLPublicRead; 
    _uploadRequest.key = [NSString stringWithFormat:@"images/user_%@.png", userId]; 
    _uploadRequest.contentType = @"image/png"; 
    _uploadRequest.body = url; 


    __weak RegistrationViewController *weakSelf = self; 

    _uploadRequest.uploadProgress = ^(int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend){ 

     dispatch_sync(dispatch_get_main_queue(), ^{ 

      weakSelf.sizeUplaoded = totalBytesSent; 
      weakSelf.filesize = totalBytesExpectedToSend; 
      [weakSelf update]; 

     }); 

    }; 

    AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager]; 
    [[transferManager upload:_uploadRequest]continueWithExecutor:[AWSExecutor mainThreadExecutor] withBlock:^id _Nullable(AWSTask * _Nonnull task) { 
     if (task.error) { 

      //NSLog(@"%@",task.error); 
      [self hideHud]; 
      [self alertView:@"Image uplaoding failed please try again." title:@"Unsuccessfull"]; 

       } 

       if (task.result) { 
        //AWSS3TransferManagerUploadOutput *uploadOutput = task.result; 
        [self hideHud]; 
        [self alertView:@"User registerd successfully." title:@"Successfull"]; 


       } 
     return nil; 
    }]; 
} 

答えて

0

ですが、あなたのアイデンティティプールは米国西部-2です。 us-east-1には存在しないので、そのリソースは見つかりませんでした。

地域AWSRegionUSEast1を更新する場合は、適切に行ってください。

関連する問題