2016-12-29 1 views
1

Xcode 프로젝트에서 s3 버킷으로 이미지를 업로드하려고합니다. 처음에는 이미지가 제대로 작동하지만 이미지를 업로드 한 후에는 매번 오류가 발생합니다. 오류s3 버킷 이미지 업로드 문제가 iOS에서 발생했습니다 (목표 C)

AWSiOSSDK v2.4.12 [오류] AWSCredentialsProvider.m 줄 : 577 | __44- [AWSCognitoCredentialsProvider 자격 증명] _block_invoke.353 | 새로 고침 할 수 없습니다. 오류 [오류 도메인 = com.amazonaws.AWSCognitoIdentityErrorDomain 코드 = 10 "(널)"사용자 정보 = {__ 유형 = 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입니다. 그것이 우리 - 동쪽 -1에 존재하지 않기 때문에, 당신은 그 자원을 찾을 수 없다는 오류를 얻습니다.

AWSRegionUSEast1 영역을 업데이트하면 잘 수행해야합니다.