问题
I want to use boto2 (2.49) to create a presigned url that uses Sign v4.
Here is my function:
c = S3Connection(access_key, secret_key)
return c.generate_url_sigv4(
expires_in=long(expiry),
method='PUT',
bucket=bucket,
key=path
)
When I run it, I got this error:
2019-06-18 12:57:51,002 boto [DEBUG]:Using access key provided by client.
2019-06-18 12:57:51,002 boto [DEBUG]:Using secret key provided by client.
Traceback (most recent call last):
File "scripts/gen_url.py", line 42, in <module>
main(key, secret)
File "scripts/gen_url.py", line 33, in main
print sign(key, secret, s3_bucket, object_name, mime_type, expires, region)
File "scripts/gen_url.py", line 21, in sign
key=path
File "/Users/antkong/Documents/Personal/wd/StackoverflowCode/python/boto2-sign-v4/python-ve/lib/python2.7/site-packages/boto/s3/connection.py", line 380, in generate_url_sigv4
return self._auth_handler.presign(http_request, expires_in,
AttributeError: 'HmacAuthV1Handler' object has no attribute 'presign'
I want to run this code in google app engine so there is no way I can put in a boto configuration. So how I can communicate to the s3 connection that I need S3SignV4
回答1:
At the end I solve the issue with an environment variable:
os.environ['S3_USE_SIGV4'] = 'True'
Just add the above line before the `S3Connection is created.
来源:https://stackoverflow.com/questions/56641244/what-does-hmacauthv1handler-object-has-no-attribute-presign-mean