def test_put_object(self):
     params = {}
     RequestParamsMapper.map_put_object_params(params, self.cli_params)
     self.assertEqual(
         params, {
             'SSECustomerAlgorithm': 'AES256',
             'SSECustomerKey': 'my-sse-c-key',
             'SSEKMSKeyId': 'my-kms-key',
             'ServerSideEncryption': 'AES256'
         })
Beispiel #2
0
 def _handle_upload(self, body):
     bucket, key = find_bucket_key(self.dest)
     params = {
         'Bucket': bucket,
         'Key': key,
         'Body': body,
     }
     self._inject_content_type(params)
     RequestParamsMapper.map_put_object_params(params, self.parameters)
     response_data = self.client.put_object(**params)
Beispiel #3
0
 def test_put_object(self):
     params = {}
     RequestParamsMapper.map_put_object_params(params, self.cli_params)
     self.assertEqual(
         params,
         {'SSECustomerAlgorithm': 'AES256',
          'SSECustomerKey': 'my-sse-c-key',
          'SSEKMSKeyId': 'my-kms-key',
          'ServerSideEncryption': 'AES256'}
     )
Beispiel #4
0
 def _handle_upload(self, body):
     bucket, key = find_bucket_key(self.dest)
     params = {
         'Bucket': bucket,
         'Key': key,
         'Body': body,
     }
     self._inject_content_type(params)
     RequestParamsMapper.map_put_object_params(params, self.parameters)
     response_data = self.client.put_object(**params)
Beispiel #5
0
 def test_put_object(self):
     params = {}
     RequestParamsMapper.map_put_object_params(params, self.cli_params)
     self.assertEqual(
         params,
         {
             "SSECustomerAlgorithm": "AES256",
             "SSECustomerKey": "my-sse-c-key",
             "SSEKMSKeyId": "my-kms-key",
             "ServerSideEncryption": "AES256",
         },
     )
Beispiel #6
0
    def _upload(self, manager, bucket, key):
        """
        Upload stdin using to the specified location.

        :type manager: s3transfer.manager.TransferManager
        :param manager: The transfer manager to use for the upload.

        :type bucket: str
        :param bucket: The bucket to upload the stream to.

        :type key: str
        :param key: The name of the key to upload the stream to.

        :return: A CommandResult representing the upload status.
        """
        expected_size = self.params.get('expected_size', None)
        subscribers = None
        if expected_size is not None:
            # `expected_size` comes in as a string
            expected_size = int(expected_size)

            # set the size of the transfer if we know it ahead of time.
            subscribers = [ProvideSizeSubscriber(expected_size)]

            # TODO: remove when this happens in s3transfer
            # If we have the expected size, we can calculate an appropriate
            # chunksize based on max parts and chunksize limits
            chunksize = find_chunksize(expected_size,
                                       self.config.multipart_chunksize)
        else:
            # TODO: remove when this happens in s3transfer
            # Otherwise, we can still adjust for chunksize limits
            chunksize = adjust_chunksize_to_upload_limits(
                self.config.multipart_chunksize)
        self.config.multipart_chunksize = chunksize

        params = {}
        RequestParamsMapper.map_put_object_params(params, self.params)

        fileobj = NonSeekableStream(binary_stdin)
        with manager:
            future = manager.upload(fileobj=fileobj,
                                    bucket=bucket,
                                    key=key,
                                    extra_args=params,
                                    subscribers=subscribers)

            return self._process_transfer(future)
 def test_put_object(self):
     params = {}
     RequestParamsMapper.map_put_object_params(params, self.cli_params)
     self.assertEqual(params, {'RequestPayer': 'requester'})
Beispiel #8
0
 def test_put_object(self):
     params = {}
     RequestParamsMapper.map_put_object_params(params, self.cli_params)
     self.assertEqual(params, {'RequestPayer': 'requester'})