jeudi 1 octobre 2015

Amazon Web Services - S3 - Identity pool id not found

I'm using xcode 6.4 for my project. The problem is I got some issue regarding to AWS S3 (Amazon Web Services S3). What I need to do is download the file from the bucket. It said Identity pool id not found but already check it several of times, same exactly inside the console. I got this error message when trying to download the file.

2015-10-01 14:44:09.470 XXXXX[9842:360833] AWSiOSSDKv2 [Error] AWSIdentityProvider.m line:185 | __51-[AWSAbstractCognitoIdentityProvider getIdentityId]_block_invoke169 | GetId failed. Error is [Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=12 "The operation couldn’t be completed. (com.amazonaws.AWSCognitoIdentityErrorDomain error 12.)" UserInfo=0x7ff56b0f1260 {__type=ResourceNotFoundException, message=IdentityPool 'ap-northeast-1:a4ef1695-XXXX-4e7c-XXXX-56f2a09eXXXX' not found.}]
2015-10-01 14:44:09.471 XXXXX[9842:360833] AWSiOSSDKv2 [Error] AWSCredentialsProvider.m line:527 | __40-[AWSCognitoCredentialsProvider refresh]_block_invoke352 | Unable to refresh. Error is [Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=12 "The operation couldn’t be completed. (com.amazonaws.AWSCognitoIdentityErrorDomain error 12.)" UserInfo=0x7ff56b0f1260 {__type=ResourceNotFoundException, message=IdentityPool 'ap-northeast-1:a4ef1695-XXXX-4e7c-XXXX-56f2a09eXXXX' not found.}]

AppDelegate.swift

import UIKit
import CoreData
import AWSS3

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    var cognitoIdentityPoolId: String = "ap-northeast-1:a4ef1695-XXXX-4e7c-XXXX-56f2a09eXXXX"

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.

        let credentialsProvider = AWSCognitoCredentialsProvider(regionType: AWSRegionType.APNortheast1, identityPoolId: cognitoIdentityPoolId)

        let defaultServiceConfiguration = AWSServiceConfiguration(
            region: AWSRegionType.USEast1, credentialsProvider: credentialsProvider)

        AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = defaultServiceConfiguration

        return true
    }

    /* -- */
}

ViewController.swift

import UIKit
import AWSS3

class ViewController: UIViewController{
    let transferManager = AWSS3TransferManager.defaultS3TransferManager()
    override func viewDidLoad() {
        super.viewDidLoad()

        var downloadingFilePath: NSString = NSTemporaryDirectory().stringByAppendingPathComponent("downloaded-myImage.gif")
        var downloadingFileURL: NSURL = NSURL.fileURLWithPath(downloadingFilePath as String)!

        var downloadRequest = AWSS3TransferManagerDownloadRequest()

        downloadRequest.bucket = "kpmgsginternalmobileapp-stg/events"
        downloadRequest.key = "myImage.gif"
        downloadRequest.downloadingFileURL = downloadingFileURL

        transferManager.download(downloadRequest).continueWithSuccessBlock({
            (task: AWSTask!) -> AWSTask! in
            dispatch_async(dispatch_get_main_queue(), {
                println("test")
            })

            return nil
        })
    }
}

Is it regarding to IAM permission issue or need set custom Authentication Provider. Please advice. Thank you.

Reference: http://ift.tt/1cLwGjz




Aucun commentaire:

Enregistrer un commentaire