【发布时间】:2017-02-05 16:16:43
【问题描述】:
我正在尝试使用适用于 Android 的 AWS 开发工具包从我的 S3 存储桶下载文件。这是我正在使用的代码:
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
getApplicationContext(),
"my identitiy pool id", // Identity Pool ID
Regions.AP_NORTHEAST_1 // Region
);
AmazonS3 s3 = new AmazonS3Client(credentialsProvider);
TransferUtility transferUtility = new TransferUtility(s3, getApplicationContext());
TransferObserver observer = transferUtility.download(
"mybucket", /* The bucket to download from */
"logo.png", /* The key for the object to download */
imageFile /* The file to download the object to */
);
此代码引发以下错误:
E/DownloadTask: Failed to download: 8 due to The provided token has expired. (Service: Amazon S3; Status Code: 400; Error Code: ExpiredToken; Request ID: 6BEA65FAFAD54BF4)
我刚刚在 AWS Cognito 上创建了凭证,它不会过期。是不是我做错了什么?
【问题讨论】:
标签: android amazon-web-services amazon-s3 aws-sdk