本文整理汇总了Python中awscli.customizations.s3.utils.RequestParamsMapper.map_get_object_params方法的典型用法代码示例。如果您正苦于以下问题:Python RequestParamsMapper.map_get_object_params方法的具体用法?Python RequestParamsMapper.map_get_object_params怎么用?Python RequestParamsMapper.map_get_object_params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类awscli.customizations.s3.utils.RequestParamsMapper
的用法示例。
在下文中一共展示了RequestParamsMapper.map_get_object_params方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_object
# 需要导入模块: from awscli.customizations.s3.utils import RequestParamsMapper [as 别名]
# 或者: from awscli.customizations.s3.utils.RequestParamsMapper import map_get_object_params [as 别名]
def test_get_object(self):
params = {}
RequestParamsMapper.map_get_object_params(params, self.cli_params)
self.assertEqual(
params,
{'SSECustomerAlgorithm': 'AES256',
'SSECustomerKey': 'my-sse-c-key'}
)
示例2: download
# 需要导入模块: from awscli.customizations.s3.utils import RequestParamsMapper [as 别名]
# 或者: from awscli.customizations.s3.utils.RequestParamsMapper import map_get_object_params [as 别名]
def download(self):
"""
Redirects the file to the multipart download function if the file is
large. If it is small enough, it gets the file as an object from s3.
"""
bucket, key = find_bucket_key(self.src)
params = {'Bucket': bucket, 'Key': key}
RequestParamsMapper.map_get_object_params(params, self.parameters)
response_data = self.client.get_object(**params)
save_file(self.dest, response_data, self.last_update,
self.is_stream)
示例3: _download_part
# 需要导入模块: from awscli.customizations.s3.utils import RequestParamsMapper [as 别名]
# 或者: from awscli.customizations.s3.utils.RequestParamsMapper import map_get_object_params [as 别名]
def _download_part(self):
total_file_size = self._filename.size
start_range = self._part_number * self._chunk_size
if self._part_number == int(total_file_size / self._chunk_size) - 1:
end_range = ''
else:
end_range = start_range + self._chunk_size - 1
range_param = 'bytes=%s-%s' % (start_range, end_range)
LOGGER.debug("Downloading bytes range of %s for file %s", range_param,
self._filename.dest)
bucket, key = find_bucket_key(self._filename.src)
params = {'Bucket': bucket,
'Key': key,
'Range': range_param}
RequestParamsMapper.map_get_object_params(params, self._params)
for i in range(self.TOTAL_ATTEMPTS):
try:
LOGGER.debug("Making GetObject requests with byte range: %s",
range_param)
response_data = self._client.get_object(**params)
LOGGER.debug("Response received from GetObject")
body = response_data['Body']
self._queue_writes(body)
self._context.announce_completed_part(self._part_number)
message = print_operation(self._filename, 0)
total_parts = int(self._filename.size / self._chunk_size)
result = {'message': message, 'error': False,
'total_parts': total_parts}
self._result_queue.put(PrintTask(**result))
LOGGER.debug("Task complete: %s", self)
return
except (socket.timeout, socket.error, ReadTimeoutError) as e:
LOGGER.debug("Timeout error caught, retrying request, "
"(attempt %s / %s)", i, self.TOTAL_ATTEMPTS,
exc_info=True)
continue
except IncompleteReadError as e:
LOGGER.debug("Incomplete read detected: %s, (attempt %s / %s)",
e, i, self.TOTAL_ATTEMPTS)
continue
raise RetriesExeededError("Maximum number of attempts exceeded: %s" %
self.TOTAL_ATTEMPTS)
示例4: test_get_object
# 需要导入模块: from awscli.customizations.s3.utils import RequestParamsMapper [as 别名]
# 或者: from awscli.customizations.s3.utils.RequestParamsMapper import map_get_object_params [as 别名]
def test_get_object(self):
params = {}
RequestParamsMapper.map_get_object_params(params, self.cli_params)
self.assertEqual(params, {"SSECustomerAlgorithm": "AES256", "SSECustomerKey": "my-sse-c-key"})