在 IOS 上使用 AWS SDK 而不使用身份池
Using AWS sdk on IOS without using Identity Pool
我想在 IOS 上使用 AWS sdk 在 S3 上传输文件。要在 IOS 上设置 AWS sdk,它需要 AWS cognito 服务为该用户提供一个身份池,但我只想使用 AWS sdk 使用访问密钥和秘密访问密钥将文件传输到 s3。
那么是否可以在 IOS 中使用 amazon sdk 而不必为此使用 amazon cognito 和其他服务。
此外,当我在 .Net 上使用 AWS sdk 时,它不需要任何其他服务,只需要访问密钥和秘密密钥。
当然可以。
查看 this section on how they configure credentials for the 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)!
)
我想在 IOS 上使用 AWS sdk 在 S3 上传输文件。要在 IOS 上设置 AWS sdk,它需要 AWS cognito 服务为该用户提供一个身份池,但我只想使用 AWS sdk 使用访问密钥和秘密访问密钥将文件传输到 s3。
那么是否可以在 IOS 中使用 amazon sdk 而不必为此使用 amazon cognito 和其他服务。
此外,当我在 .Net 上使用 AWS sdk 时,它不需要任何其他服务,只需要访问密钥和秘密密钥。
当然可以。
查看 this section on how they configure credentials for the 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)!
)