- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想从已激活加速的 S3 存储桶中将文件下载到 Python 文件对象中。我遇到了一些建议是否覆盖 endpoint_url
的资源。到“s3-accelerate.amazonaws.com”和/或使用 use_accelerate_endpoint
属性。
我已经尝试了这两种方法,并尝试了几种变体,但每次都返回相同的错误。我试过的脚本之一是:
from botocore.config import Config
import boto3
from io import BytesIO
session = boto3.session.Session()
s3 = session.client(
service_name='s3',
aws_access_key_id=<MY_KEY_ID>,
aws_secret_access_key=<MY_KEY>,
region_name="us-west-2",
config=Config(s3={"use_accelerate_endpoint": True,
"addressing_style": "path"}))
input = BytesIO()
s3.download_fileobj(<MY_BUCKET>,<MY_KEY>, input)
---------------------------------------------------------------------------
ClientError Traceback (most recent call last)
<ipython-input-61-92b89b45f215> in <module>()
11 "addressing_style": "path"}))
12 input = BytesIO()
---> 13 s3.download_fileobj(bucket, filename, input)
14
15
~/Project/venv/lib/python3.5/site-packages/boto3/s3/inject.py in download_fileobj(self, Bucket, Key, Fileobj, ExtraArgs, Callback, Config)
568 bucket=Bucket, key=Key, fileobj=Fileobj,
569 extra_args=ExtraArgs, subscribers=subscribers)
--> 570 return future.result()
571
572
~/Project//venv/lib/python3.5/site-packages/s3transfer/futures.py in result(self)
71 # however if a KeyboardInterrupt is raised we want want to exit
72 # out of this and propogate the exception.
---> 73 return self._coordinator.result()
74 except KeyboardInterrupt as e:
75 self.cancel()
~/Project/venv/lib/python3.5/site-packages/s3transfer/futures.py in result(self)
231 # final result.
232 if self._exception:
--> 233 raise self._exception
234 return self._result
235
~/Project/venv/lib/python3.5/site-packages/s3transfer/tasks.py in _main(self, transfer_future, **kwargs)
253 # Call the submit method to start submitting tasks to execute the
254 # transfer.
--> 255 self._submit(transfer_future=transfer_future, **kwargs)
256 except BaseException as e:
257 # If there was an exception raised during the submission of task
~/Project/venv/lib/python3.5/site-packages/s3transfer/download.py in _submit(self, client, config, osutil, request_executor, io_executor, transfer_future)
347 Bucket=transfer_future.meta.call_args.bucket,
348 Key=transfer_future.meta.call_args.key,
--> 349 **transfer_future.meta.call_args.extra_args
350 )
351 transfer_future.meta.provide_transfer_size(
~/Project/venv/lib/python3.5/site-packages/botocore/client.py in _api_call(self, *args, **kwargs)
310 "%s() only accepts keyword arguments." % py_operation_name)
311 # The "self" in this scope is referring to the BaseClient.
--> 312 return self._make_api_call(operation_name, kwargs)
313
314 _api_call.__name__ = str(py_operation_name)
~/Project/venv/lib/python3.5/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params)
603 error_code = parsed_response.get("Error", {}).get("Code")
604 error_class = self.exceptions.from_code(error_code)
--> 605 raise error_class(parsed_response, operation_name)
606 else:
607 return parsed_response
ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden
"use_accelerate_endpoint": False
运行相同的脚本时它工作正常。
endpoint_url
与“s3-accelerate.amazonaws.com”"addressing_style": "virtual"
s3.get_bucket_accelerate_configuration(Bucket=<MY_BUCKET>)
{..., 'Status': 'Enabled'}
正如预期的那样。
from botocore.config import Config
import boto3
from io import BytesIO
session = boto3.session.Session()
s3 = session.client(
service_name='s3',
aws_access_key_id=<MY_KEY_ID>,
aws_secret_access_key=<MY_KEY>,
region_name="us-west-2",
config=Config(s3={"use_accelerate_endpoint": True,
"addressing_style": "virtual"}))
output = BytesIO()
output.seek(0)
s3.upload_fileobj(output, <MY_BUCKET>,<MY_KEY>)
use_accelerate_endpoint
的情况下工作选项(所以我的键没问题),但在 True 时返回此错误:
ClientError: An error occurred (SignatureDoesNotMatch) when calling the PutObject operation: The request signature we calculated does not match the signature you provided. Check your key and signing method.
addressing_style
此处也有选项(虚拟和路径)
最佳答案
使用 boto3==1.4.7
和 botocore==1.7.43
.
这是从启用了传输加速的存储桶中检索对象的一种方法。
import boto3
from botocore.config import Config
from io import BytesIO
config = Config(s3={"use_accelerate_endpoint": True})
s3_resource = boto3.resource("s3",
aws_access_key_id=<MY_KEY_ID>,
aws_secret_access_key=<MY_KEY>,
region_name="us-west-2",
config=config)
s3_client = s3_resource.meta.client
file_object = BytesIO()
s3_client.download_fileobj(<MY_BUCKET>, <MY_KEY>, file_object)
HEAD
在
GET
之前向加速端点发出请求.
CanonicalRequest:
HEAD
/<MY_KEY>
host:<MY_BUCKET>.s3-accelerate.amazonaws.com
x-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
x-amz-date:20200520T204128Z
host;x-amz-content-sha256;x-amz-date
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
HEAD
的一些原因请求可能失败包括:
关于python-3.x - 使用 boto3 连接到 S3 加速端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47295978/
我已经阅读了关于“describe_cluster_snapshots”的解释...... http://docs.pythonboto.org/en/latest/ref/redshift.html
根据 DynamoDB 文档,如果使用受支持的 SDK,导致数据库节流的请求会自动重试。但是,我找不到任何关于 boto 如何处理节流情况的提及。 boto 会自动重试受限请求还是我应该开始捕获 Pr
有没有办法在 SQS 队列中设置消息的消息属性?我正在尝试检查发送到 SQS 队列的消息并更改其值。下面代码的最后一行获取并打印该值。 for message in queue.receive_mes
我无法从文档/示例中确定如何使用 boto 的 dynamodb2 从 DynamoDB 存储/读取二进制数据。它是如何完成的? 我的猜测是项目值类似于 { 'B': binary-data }但这会
我想获取 dynamodb 表的唯一哈希键值列表。我目前知道的唯一方法是扫描整个表,然后迭代扫描。什么是更好的方法? 最佳答案 rs = list(table.scan(range__eq="rang
我正在使用 boto 访问 dynamodb 表。一切顺利,直到我尝试执行扫描操作。 我尝试了在互联网上反复搜索后发现的几种语法,但没有成功: def scanAssets(self, asset):
我正在使用 Boto 库与 AWS 通信。我想禁用日志记录。 (或重定向到/dev/null 或其他文件)。我找不到明显的方法来做到这一点。我试过了,但这似乎没有帮助: import boto bot
这是我尝试将文档上传到云搜索的代码 from boto.cloudsearch2.layer2 import Layer2 conn_config = { 'region': 'us-east
我已经尝试过: connection = S3Connection( aws_access_key_id=settings.AWS_ACCESS_KEY_ID, aws_secret_
我正在编写一个脚本,以确保我们所有的 EC2 实例都有 DNS 条目,并且所有 DNS 条目都指向有效的 EC2 实例。 我的方法是尝试获取我们域的所有资源记录,以便在检查实例名称时可以遍历列表。 但
查看 boto 文档,当您将消息标识符从 SQS 队列中取出时,我没有看到获取消息标识符的方法。谁能提供一些有关我如何获取这些信息的信息? 最佳答案 Message实例应该有一个名为 id 的属性其中
我的python程序的第一行是from boto.s3.connection import S3Connection . 当我执行程序时,输出是“from: can't read/var/mail/b
我在使用 DynamoDB2 API 使用 boto 2.9.5 执行任何单个或批处理查询时遇到问题 我需要做一个这样的批量查询: one_org = Table('[table-name]').ba
我的网站正在使用 Django+Gunicorn+GEvent。 有一个功能,我必须将 Boto 用于 DynamoDB。 我需要调用monkey.patch_all() 来让Boto 变成green
我不断从包含在结构任务中的 boto create_launch_configuration() cmd 返回此错误。 这是命令: if user_data != '': security_group
我想使用 boto 获取 LoadBalancer 上的所有实例,我该如何实现? 这是我到目前为止所得到的: import boto from boto.regioninfo import Regio
标题已经说明问题了。 我正在请求一个带有 boto 的 Spot 实例,如下所示(aws key 和 secret key 是 ~/.boto 中设置的环境变量): import boto conn
我有一个我注册为亚马逊开发者的账户。 (我们称其为 developer 帐户) 我有另一个账户,我将其视为卖家账户(也是亚马逊开发者账户)。 (我们称此为seller 帐户) 我希望我的开发者帐户代表
如果存储桶名称有大写字母,我将无法连接到存储桶。 我有几个桶,里面有大写字母。 >>> mybucket = conn.get_bucket('Vig_import') Traceback (most
Boto在AWS上下文中代表什么?选择api名称似乎是一个随意的单词。是缩写吗?我已尝试使用Google搜索功能,但未发现其含义。 最佳答案 Boto的名称源于对亚马逊河原生海豚类型的葡萄牙语名称。
我是一名优秀的程序员,十分优秀!