首页 > 解决方案 > Using AWS sdk on IOS without using Identity Pool

问题描述

I want to use AWS sdk on IOS to transfer files on S3. To setup AWS sdk on IOS it requires AWS cognito service to have an identity pool for that user but I just want to use AWS sdk to transfer files to s3 using access key and secret access key.

So is it possible to use amazon sdk for IOS without having to use amazon cognito and other service for that matter.

Also when I use AWS sdk on .Net it doesnt require any other service just access key and scret key.

标签: iosamazon-s3aws-sdk

解决方案


当然,你可以这样做。

查看本节,了解他们如何为 TransferUtility 配置凭据。在这里,他们使用 Cognito 作为凭证​​提供者。

let credentialProvider = AWSCognitoCredentialsProvider(regionType: YOUR-IDENTITY-POOL-REGION, identityPoolId: "YOUR-IDENTITY-POOL-ID")  

相反,您可以使用使用 IAM 用户的访问密钥 ID 和密钥的静态凭证提供程序:

let credentialsProvider = AWSStaticCredentialsProvider(accessKey: "YOUR-ACCESS-KEY-ID", secretKey: "YOUR-SECRET-KEY")

当您实例化 S3 服务时,您将提供凭证提供程序接口作为AWSServiceConfiguration. 正如他们对传输实用程序所做的那样:

//Register a transfer utility object
AWSS3TransferUtility.register(
    with: AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialProvider)!
)

推荐阅读