当我尝试从 s3 检索文件时遇到问题。我能够按预期连接到 s3 存储桶,但是当我尝试检索文件时,出现以下错误。
凭证是从我的中获取的./aws/credentials
,我可以使用 AWS CLI 从本地下载相同的文件。
有什么想法这里可能有什么问题吗?
Error:
awsError
code = ExpiredToken
message = The provided token has expired.
statusCode = 400
Result, err := client.GetObject(&s3.GetObjectInput{
Bucket: &bucket,
Key: &Key,
ResponseContentType: aws.String("application/json"),
})
if err != nil {
logger.Errorf("Unable to retrieve file the file", err.Error())
return nil, http.StatusInternalServerError
}
Run Code Online (Sandbox Code Playgroud)