Example #1
0
    def test_can_send_extra_params_on_upload(self):
        transfer = self.create_s3_transfer()
        filename = self.files.create_file_with_size('foo.txt', filesize=1024)
        transfer.upload_file(filename, self.bucket_name,
                             'foo.txt', extra_args={'ACL': 'public-read'})
        self.addCleanup(self.delete_object, 'foo.txt')

        response = self.client.get_object_acl(
            Bucket=self.bucket_name, Key='foo.txt')
        self.assert_has_public_read_acl(response)
Example #2
0
 def test_upload_above_threshold(self):
     config = boto3_wasabi.s3.transfer.TransferConfig(
         multipart_threshold=2 * 1024 * 1024)
     transfer = self.create_s3_transfer(config)
     filename = self.files.create_file_with_size(
         '20mb.txt', filesize=20 * 1024 * 1024)
     transfer.upload_file(filename, self.bucket_name,
                          '20mb.txt')
     self.addCleanup(self.delete_object, '20mb.txt')
     self.assertTrue(self.object_exists('20mb.txt'))
Example #3
0
    def test_upload_file_above_threshold_with_acl(self):
        config = boto3_wasabi.s3.transfer.TransferConfig(
            multipart_threshold=5 * 1024 * 1024)
        transfer = self.create_s3_transfer(config)
        filename = self.files.create_file_with_size(
            '6mb.txt', filesize=6 * 1024 * 1024)
        extra_args = {'ACL': 'public-read'}
        transfer.upload_file(filename, self.bucket_name,
                             '6mb.txt', extra_args=extra_args)
        self.addCleanup(self.delete_object, '6mb.txt')

        self.assertTrue(self.object_exists('6mb.txt'))
        response = self.client.get_object_acl(
            Bucket=self.bucket_name, Key='6mb.txt')
        self.assert_has_public_read_acl(response)
Example #4
0
    def test_callback_called_once_with_sigv4(self):
        # Verify #98, where the callback was being invoked
        # twice when using signature version 4.
        self.amount_seen = 0
        lock = threading.Lock()
        def progress_callback(amount):
            with lock:
                self.amount_seen += amount

        client = self.session.client(
            's3', self.region,
            config=Config(signature_version='s3v4'))
        transfer = boto3_wasabi.s3.transfer.S3Transfer(client)
        filename = self.files.create_file_with_size(
            '10mb.txt', filesize=10 * 1024 * 1024)
        transfer.upload_file(filename, self.bucket_name,
                             '10mb.txt', callback=progress_callback)
        self.addCleanup(self.delete_object, '10mb.txt')

        self.assertEqual(self.amount_seen, 10 * 1024 * 1024)
Example #5
0
    def test_progress_callback_on_upload(self):
        self.amount_seen = 0
        lock = threading.Lock()

        def progress_callback(amount):
            with lock:
                self.amount_seen += amount

        transfer = self.create_s3_transfer()
        filename = self.files.create_file_with_size(
            '20mb.txt', filesize=20 * 1024 * 1024)
        transfer.upload_file(filename, self.bucket_name,
                             '20mb.txt', callback=progress_callback)
        self.addCleanup(self.delete_object, '20mb.txt')

        # The callback should have been called enough times such that
        # the total amount of bytes we've seen (via the "amount"
        # arg to the callback function) should be the size
        # of the file we uploaded.
        self.assertEqual(self.amount_seen, 20 * 1024 * 1024)
Example #6
0
 def test_upload_file_above_threshold_with_ssec(self):
     key_bytes = os.urandom(32)
     extra_args = {
         'SSECustomerKey': key_bytes,
         'SSECustomerAlgorithm': 'AES256',
     }
     config = boto3_wasabi.s3.transfer.TransferConfig(
         multipart_threshold=5 * 1024 * 1024)
     transfer = self.create_s3_transfer(config)
     filename = self.files.create_file_with_size(
         '6mb.txt', filesize=6 * 1024 * 1024)
     transfer.upload_file(filename, self.bucket_name,
                          '6mb.txt', extra_args=extra_args)
     self.addCleanup(self.delete_object, '6mb.txt')
     # A head object will fail if it has a customer key
     # associated with it and it's not provided in the HeadObject
     # request so we can use this to verify our functionality.
     response = self.client.head_object(
         Bucket=self.bucket_name,
         Key='6mb.txt', **extra_args)
     self.assertEqual(response['SSECustomerAlgorithm'], 'AES256')