问题描述
在开发时,我在爱尔兰使用了一个S3存储桶,效果很好.为了进行生产,我想使用S3的新法兰克福"位置,但是显然,新的法兰克福地区使用了"SigV4",它破坏了我的python脚本.
when developing i used a S3 bucket in ireland, which worked well. For production i want to use the new "Frankfurt" location of S3, but apparently the new Frankfurt region uses the "SigV4" which breaks my python script.
将以下代码块添加到〜/.boto时,出现以下错误:
When adding the following block to ~/.boto, i get the following error:
〜/.boto:
[s3]
use-sigv4 = True
错误:
File "/usr/lib/python2.6/site-packages/boto/__init__.py", line 141, in connect_s3
return S3Connection(aws_access_key_id, aws_secret_access_key, **kwargs)
File "/usr/lib/python2.6/site-packages/boto/s3/connection.py", line 196, in __init__
"When using SigV4, you must specify a 'host' parameter."
boto.s3.connection.HostRequiredError: BotoClientError: When using SigV4,
you must specify a 'host' parameter.
有人可以告诉我如何指定主机"参数吗?我在aws/boto文档中找不到此参数.
Can anybody please tell me how to specify the "host" parameter? I couldn't find this parameter in a aws/boto documentation.
推荐答案
这里是针对您的确切错误的文档,以及确切源代码来创建S3Connection
(进而是您的错误).
Here's the docs for your exact error, as well as the exact source code that's creating the S3Connection
(and in turn, your error).
在创建S3Connection(aws_access_key_id, aws_secret_access_key, **kwargs)
时,您需要传递一个附加项目host=...
,该项目应该是一个简单的字符串,例如's3.amazonaws.com'
,或与您的设置类似的字符串.
In creating the S3Connection(aws_access_key_id, aws_secret_access_key, **kwargs)
, you need to pass in an additional item host=...
, which should be a simple string like 's3.amazonaws.com'
, or similar for your setup.
解决方案:
您可以将其添加到正在传递的kwargs
中:
You can add this to your kwargs
being passed:
kwargs.update({'host': 's3.amazonaws.com'})
或手动调用它,如:
S3Connection(aws_access_key_id, aws_secret_access_key, host='s3.amazonaws.com', **kwargs)
这篇关于使用Boto和SigV4的S3-缺少主机参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!