gpt4 book ai didi

objective-c - AWS S3 返回 "Identity pool id not found"

转载 作者:搜寻专家 更新时间:2023-11-01 06:21:42 27 4
gpt4 key购买 nike

我正在为我的项目使用 xcode 6.4。问题是我遇到了一些关于 AWS S3 (Amazon Web Services S3) 的问题。我需要做的是从存储桶中下载文件。它说找不到身份池 ID 但已经检查了几次,在控制台内完全相同。我在尝试下载文件时收到此错误消息。

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.APNortheast1, 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 = "xxxxxx-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
})
}
}

是关于 IAM 策略问题还是需要设置自定义身份验证提供程序?

引用:http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html

最佳答案

确保您已设置 IAM 政策。它位于 IAM -> 角色 -> 内联策略 -> 编辑策略下。它看起来应该与此类似:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"mobileanalytics:PutEvents",
"cognito-sync:*",
"s3:*"
],
"Resource": [
"*"
]
}
]
}

关于objective-c - AWS S3 返回 "Identity pool id not found",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32881245/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com