我正在使用boto3的s3.transfer从s3下载几个4GB +文件。所有,但一个能下载,但失败的人给了以下错误:在http://boto3.readthedocs.org/en/latest/_modules/boto3/s3/transfer.html如何增加boto3.s3.transfer下载的令牌过期时间?
s3_client = session.client('s3')
transfer = S3Transfer(s3_client)
# Download s3://bucket/key to /tmp/myfile
transfer.download_file('bucket', 'key', '/tmp/myfile')
ERROR: An error occurred (ExpiredToken) when calling the GetObject operation: The provided token has expired.
我现在用同样的方式是文件是否有增加的方式boto3中使用的签名url的过期时间?
如果它是相关的,我使用Cognito拿到证书,并与他们,会话
client = boto3.client('cognito-identity', AWS_REGION)
# credentials[] contains the IdentityId and Token I get from my server
# which I get using client.get_open_id_token_for_developer_identity
# with TokenDuration=86400
resp = client.get_credentials_for_identity(IdentityId=credentials['IdentityId'],
Logins={'cognito-identity.amazonaws.com': credentials['Token']})
# The resp contains the actual temporary AWS secret/access codes and a session token, to be
# used with the rest of the AWS APIs
secretKey = resp['Credentials']['SecretKey']
accessKey = resp['Credentials']['AccessKeyId']
sessionToken = resp['Credentials']['SessionToken']
session = Session(aws_access_key_id=accessKey,
aws_secret_access_key=secretKey,
aws_session_token=sessionToken,
region_name=AWS_REGION)
s3_client = session.client('s3')
您的代码如何接收访问密钥/密钥?我的猜测是你的问题是代码在一个附加了IAM角色的EC2实例上运行。它是否正确 ?或者你是否通过配置文件传递AK/SK? ENV变量? –
忘记提及我使用cognito获取密钥,访问密钥和会话令牌。 – dkarchmer
更新了OP,代码显示了我是如何获得会话和s3客户端的 – dkarchmer