"HmacAuthV1Handler"对象没有属性"presign"是什么意思? [英] What does ''HmacAuthV1Handler' object has no attribute 'presign'' mean?

查看:90
本文介绍了"HmacAuthV1Handler"对象没有属性"presign"是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用boto2(2.49)创建一个使用Sign v4的预签名网址.

I want to use boto2 (2.49) to create a presigned url that uses Sign v4.

这是我的功能:

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'

我想在Google App Engine中运行此代码,因此无法将其放入Boto配置中.因此,如何与需要 S3SignV4

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

推荐答案

最后,我使用环境变量解决了这个问题:

At the end I solve the issue with an environment variable:

os.environ['S3_USE_SIGV4'] = 'True'

只需在创建S3Connection之前添加以上行即可.

Just add the above line before the `S3Connection is created.

这篇关于"HmacAuthV1Handler"对象没有属性"presign"是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆