1
我試圖使用適用於Android的AWS開發工具包從S3存儲桶中下載文件。下面是我使用的代碼:從S3下載文件時AWS令牌已過期
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的憑證,它cannnot到期。有什麼我做錯了嗎?