当前位置: 首页>>代码示例>>Python>>正文


Python RequestParamsMapper.map_upload_part_params方法代码示例

本文整理汇总了Python中awscli.customizations.s3.utils.RequestParamsMapper.map_upload_part_params方法的典型用法代码示例。如果您正苦于以下问题:Python RequestParamsMapper.map_upload_part_params方法的具体用法?Python RequestParamsMapper.map_upload_part_params怎么用?Python RequestParamsMapper.map_upload_part_params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在awscli.customizations.s3.utils.RequestParamsMapper的用法示例。


在下文中一共展示了RequestParamsMapper.map_upload_part_params方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_upload_part

# 需要导入模块: from awscli.customizations.s3.utils import RequestParamsMapper [as 别名]
# 或者: from awscli.customizations.s3.utils.RequestParamsMapper import map_upload_part_params [as 别名]
 def test_upload_part(self):
     params = {}
     RequestParamsMapper.map_upload_part_params(params, self.cli_params)
     self.assertEqual(
         params,
         {'SSECustomerAlgorithm': 'AES256',
          'SSECustomerKey': 'my-sse-c-key'}
     )
开发者ID:rnaveiras,项目名称:aws-cli,代码行数:10,代码来源:test_utils.py

示例2: __call__

# 需要导入模块: from awscli.customizations.s3.utils import RequestParamsMapper [as 别名]
# 或者: from awscli.customizations.s3.utils.RequestParamsMapper import map_upload_part_params [as 别名]
    def __call__(self):
        LOGGER.debug("Uploading part %s for filename: %s",
                     self._part_number, self._filename.src)
        try:
            LOGGER.debug("Waiting for upload id.")
            upload_id = self._upload_context.wait_for_upload_id()
            bucket, key = find_bucket_key(self._filename.dest)
            if self._filename.is_stream:
                body = self._payload
                total = self._upload_context.expected_parts
            else:
                total = int(math.ceil(
                    self._filename.size/float(self._chunk_size)))
                body = self._read_part()
            params = {'Bucket': bucket, 'Key': key,
                      'PartNumber': self._part_number,
                      'UploadId': upload_id,
                      'Body': body}
            RequestParamsMapper.map_upload_part_params(params, self._params)
            try:
                response_data = self._filename.client.upload_part(**params)
            finally:
                body.close()
            etag = response_data['ETag'][1:-1]
            self._upload_context.announce_finished_part(
                etag=etag, part_number=self._part_number)

            message = print_operation(self._filename, 0)
            result = {'message': message, 'total_parts': total,
                      'error': False}
            self._result_queue.put(PrintTask(**result))
        except UploadCancelledError as e:
            # We don't need to do anything in this case.  The task
            # has been cancelled, and the task that cancelled the
            # task has already queued a message.
            LOGGER.debug("Not uploading part, task has been cancelled.")
        except Exception as e:
            LOGGER.debug('Error during part upload: %s', e,
                         exc_info=True)
            message = print_operation(self._filename, failed=True,
                                      dryrun=False)
            message += '\n' + str(e)
            result = {'message': message, 'error': True}
            self._result_queue.put(PrintTask(**result))
            self._upload_context.cancel_upload()
        else:
            LOGGER.debug("Part number %s completed for filename: %s",
                         self._part_number, self._filename.src)
开发者ID:Athena88,项目名称:aws-cli,代码行数:50,代码来源:tasks.py

示例3: test_upload_part

# 需要导入模块: from awscli.customizations.s3.utils import RequestParamsMapper [as 别名]
# 或者: from awscli.customizations.s3.utils.RequestParamsMapper import map_upload_part_params [as 别名]
 def test_upload_part(self):
     params = {}
     RequestParamsMapper.map_upload_part_params(params, self.cli_params)
     self.assertEqual(params, {"SSECustomerAlgorithm": "AES256", "SSECustomerKey": "my-sse-c-key"})
开发者ID:aws,项目名称:aws-cli,代码行数:6,代码来源:test_utils.py


注:本文中的awscli.customizations.s3.utils.RequestParamsMapper.map_upload_part_params方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。