Python boto3.s3.transfer.TransferConfig() Examples
The following are 30
code examples of boto3.s3.transfer.TransferConfig().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
boto3.s3.transfer
, or try the search function
.
Example #1
Source File: get.py From z3 with Apache License 2.0 | 6 votes |
def main(): cfg = get_config() parser = argparse.ArgumentParser( description='Read a key from s3 and write the content to stdout', ) parser.add_argument('name', help='name of S3 key') args = parser.parse_args() extra_config = {} if 'HOST' in cfg: extra_config['endpoint_url'] = cfg['HOST'] config = TransferConfig(max_concurrency=int(cfg['CONCURRENCY']), multipart_chunksize=int(re.sub('M', '', cfg['CHUNK_SIZE'])) * MB) if 'S3_KEY_ID' in cfg: s3 = boto3.client('s3', aws_access_key_id=cfg['S3_KEY_ID'], aws_secret_access_key=cfg['S3_SECRET'], **extra_config) else: s3 = boto3.client('s3', **extra_config) try: s3.download_fileobj(cfg['BUCKET'], args.name, sys.stdout, Config=config) except botocore.exceptions.ClientError as e: if e.response['Error']['Code'] == "404": print("The object does not exist.") else: raise
Example #2
Source File: s3.py From d6tpipe with MIT License | 6 votes |
def put_multipart(self, local_path, destination_s3_path, part_size=DEFAULT_PART_SIZE, **kwargs): """ Put an object stored locally to an S3 path using S3 multi-part upload (for files > 8Mb). :param local_path: Path to source local file :param destination_s3_path: URL for target S3 location :param part_size: Part size in bytes. Default: 8388608 (8MB) :param kwargs: Keyword arguments are passed to the boto function `upload_fileobj` as ExtraArgs """ self._check_deprecated_argument(**kwargs) from boto3.s3.transfer import TransferConfig # default part size for boto3 is 8Mb, changing it to fit part_size # provided as a parameter transfer_config = TransferConfig(multipart_chunksize=part_size) (bucket, key) = self._path_to_bucket_and_key(destination_s3_path) self.s3.meta.client.upload_fileobj( Fileobj=open(local_path, 'rb'), Bucket=bucket, Key=key, Config=transfer_config, ExtraArgs=kwargs)
Example #3
Source File: prepare_lm_data.py From grover with Apache License 2.0 | 6 votes |
def close(self): self.writer.close() if self.s3client is not None: from boto3.s3.transfer import TransferConfig config = TransferConfig(multipart_threshold=1024 * 25, max_concurrency=10, multipart_chunksize=1024 * 25, use_threads=True) self.s3client.upload_file( os.path.join(self.storage_dir.name, 'temp.tfrecord'), self.bucket_name, self.file_name, ExtraArgs={'ACL': 'public-read'}, Config=config, ) self.storage_dir.cleanup() if self.gclient is not None: bucket = self.gclient.get_bucket(self.bucket_name) blob = bucket.blob(self.file_name) blob.upload_from_filename(os.path.join(self.storage_dir.name, 'temp.tfrecord')) self.storage_dir.cleanup()
Example #4
Source File: inject.py From aws-builders-fair-projects with Apache License 2.0 | 5 votes |
def download_file(self, Bucket, Key, Filename, ExtraArgs=None, Callback=None, Config=None): """Download an S3 object to a file. Usage:: import boto3 s3 = boto3.resource('s3') s3.meta.client.download_file('mybucket', 'hello.txt', '/tmp/hello.txt') Similar behavior as S3Transfer's download_file() method, except that parameters are capitalized. Detailed examples can be found at :ref:`S3Transfer's Usage <ref_s3transfer_usage>`. :type Bucket: str :param Bucket: The name of the bucket to download from. :type Key: str :param Key: The name of the key to download from. :type Filename: str :param Filename: The path to the file to download to. :type ExtraArgs: dict :param ExtraArgs: Extra arguments that may be passed to the client operation. :type Callback: function :param Callback: A method which takes a number of bytes transferred to be periodically called during the download. :type Config: boto3.s3.transfer.TransferConfig :param Config: The transfer configuration to be used when performing the transfer. """ with S3Transfer(self, Config) as transfer: return transfer.download_file( bucket=Bucket, key=Key, filename=Filename, extra_args=ExtraArgs, callback=Callback)
Example #5
Source File: service_resource.py From boto3_type_annotations with MIT License | 5 votes |
def copy(self, CopySource: Dict = None, Key: str = None, ExtraArgs: Dict = None, Callback: Callable = None, SourceClient: BaseClient = None, Config: TransferConfig = None): pass
Example #6
Source File: service_resource.py From boto3_type_annotations with MIT License | 5 votes |
def download_file(self, Key: str = None, Filename: str = None, ExtraArgs: Dict = None, Callback: Callable = None, Config: TransferConfig = None): pass
Example #7
Source File: client.py From boto3_type_annotations with MIT License | 5 votes |
def download_fileobj(self, Fileobj: IO = None, Bucket: str = None, Key: str = None, ExtraArgs: Dict = None, Callback: Callable = None, Config: TransferConfig = None): pass
Example #8
Source File: inject.py From aws-builders-fair-projects with Apache License 2.0 | 5 votes |
def bucket_upload_fileobj(self, Fileobj, Key, ExtraArgs=None, Callback=None, Config=None): """Upload a file-like object to this bucket. The file-like object must be in binary mode. This is a managed transfer which will perform a multipart upload in multiple threads if necessary. Usage:: import boto3 s3 = boto3.resource('s3') bucket = s3.Bucket('mybucket') with open('filename', 'rb') as data: bucket.upload_fileobj(data, 'mykey') :type Fileobj: a file-like object :param Fileobj: A file-like object to upload. At a minimum, it must implement the `read` method, and must return bytes. :type Key: str :param Key: The name of the key to upload to. :type ExtraArgs: dict :param ExtraArgs: Extra arguments that may be passed to the client operation. :type Callback: function :param Callback: A method which takes a number of bytes transferred to be periodically called during the upload. :type Config: boto3.s3.transfer.TransferConfig :param Config: The transfer configuration to be used when performing the upload. """ return self.meta.client.upload_fileobj( Fileobj=Fileobj, Bucket=self.name, Key=Key, ExtraArgs=ExtraArgs, Callback=Callback, Config=Config)
Example #9
Source File: inject.py From aws-builders-fair-projects with Apache License 2.0 | 5 votes |
def object_upload_file(self, Filename, ExtraArgs=None, Callback=None, Config=None): """Upload a file to an S3 object. Usage:: import boto3 s3 = boto3.resource('s3') s3.Object('mybucket', 'hello.txt').upload_file('/tmp/hello.txt') Similar behavior as S3Transfer's upload_file() method, except that parameters are capitalized. Detailed examples can be found at :ref:`S3Transfer's Usage <ref_s3transfer_usage>`. :type Filename: str :param Filename: The path to the file to upload. :type ExtraArgs: dict :param ExtraArgs: Extra arguments that may be passed to the client operation. :type Callback: function :param Callback: A method which takes a number of bytes transferred to be periodically called during the upload. :type Config: boto3.s3.transfer.TransferConfig :param Config: The transfer configuration to be used when performing the transfer. """ return self.meta.client.upload_file( Filename=Filename, Bucket=self.bucket_name, Key=self.key, ExtraArgs=ExtraArgs, Callback=Callback, Config=Config)
Example #10
Source File: inject.py From aws-builders-fair-projects with Apache License 2.0 | 5 votes |
def bucket_download_file(self, Key, Filename, ExtraArgs=None, Callback=None, Config=None): """Download an S3 object to a file. Usage:: import boto3 s3 = boto3.resource('s3') s3.Bucket('mybucket').download_file('hello.txt', '/tmp/hello.txt') Similar behavior as S3Transfer's download_file() method, except that parameters are capitalized. Detailed examples can be found at :ref:`S3Transfer's Usage <ref_s3transfer_usage>`. :type Key: str :param Key: The name of the key to download from. :type Filename: str :param Filename: The path to the file to download to. :type ExtraArgs: dict :param ExtraArgs: Extra arguments that may be passed to the client operation. :type Callback: function :param Callback: A method which takes a number of bytes transferred to be periodically called during the download. :type Config: boto3.s3.transfer.TransferConfig :param Config: The transfer configuration to be used when performing the transfer. """ return self.meta.client.download_file( Bucket=self.name, Key=Key, Filename=Filename, ExtraArgs=ExtraArgs, Callback=Callback, Config=Config)
Example #11
Source File: inject.py From aws-builders-fair-projects with Apache License 2.0 | 5 votes |
def bucket_upload_file(self, Filename, Key, ExtraArgs=None, Callback=None, Config=None): """Upload a file to an S3 object. Usage:: import boto3 s3 = boto3.resource('s3') s3.Bucket('mybucket').upload_file('/tmp/hello.txt', 'hello.txt') Similar behavior as S3Transfer's upload_file() method, except that parameters are capitalized. Detailed examples can be found at :ref:`S3Transfer's Usage <ref_s3transfer_usage>`. :type Filename: str :param Filename: The path to the file to upload. :type Key: str :param Key: The name of the key to upload to. :type ExtraArgs: dict :param ExtraArgs: Extra arguments that may be passed to the client operation. :type Callback: function :param Callback: A method which takes a number of bytes transferred to be periodically called during the upload. :type Config: boto3.s3.transfer.TransferConfig :param Config: The transfer configuration to be used when performing the transfer. """ return self.meta.client.upload_file( Filename=Filename, Bucket=self.name, Key=Key, ExtraArgs=ExtraArgs, Callback=Callback, Config=Config)
Example #12
Source File: service_resource.py From boto3_type_annotations with MIT License | 5 votes |
def download_file(self, Filename: str = None, ExtraArgs: Dict = None, Callback: Callable = None, Config: TransferConfig = None): pass
Example #13
Source File: inject.py From aws-builders-fair-projects with Apache License 2.0 | 5 votes |
def upload_file(self, Filename, Bucket, Key, ExtraArgs=None, Callback=None, Config=None): """Upload a file to an S3 object. Usage:: import boto3 s3 = boto3.resource('s3') s3.meta.client.upload_file('/tmp/hello.txt', 'mybucket', 'hello.txt') Similar behavior as S3Transfer's upload_file() method, except that parameters are capitalized. Detailed examples can be found at :ref:`S3Transfer's Usage <ref_s3transfer_usage>`. :type Filename: str :param Filename: The path to the file to upload. :type Bucket: str :param Bucket: The name of the bucket to upload to. :type Key: str :param Key: The name of the key to upload to. :type ExtraArgs: dict :param ExtraArgs: Extra arguments that may be passed to the client operation. :type Callback: function :param Callback: A method which takes a number of bytes transferred to be periodically called during the upload. :type Config: boto3.s3.transfer.TransferConfig :param Config: The transfer configuration to be used when performing the transfer. """ with S3Transfer(self, Config) as transfer: return transfer.upload_file( filename=Filename, bucket=Bucket, key=Key, extra_args=ExtraArgs, callback=Callback)
Example #14
Source File: client.py From boto3_type_annotations with MIT License | 5 votes |
def upload_fileobj(self, Fileobj: IO = None, Bucket: str = None, Key: str = None, ExtraArgs: Dict = None, Callback: Callable = None, Config: TransferConfig = None): pass
Example #15
Source File: client.py From boto3_type_annotations with MIT License | 5 votes |
def upload_file(self, Filename: str = None, Bucket: str = None, Key: str = None, ExtraArgs: Dict = None, Callback: Callable = None, Config: TransferConfig = None): pass
Example #16
Source File: service_resource.py From boto3_type_annotations with MIT License | 5 votes |
def upload_fileobj(self, Fileobj: IO = None, Key: str = None, ExtraArgs: Dict = None, Callback: Callable = None, Config: TransferConfig = None): pass
Example #17
Source File: service_resource.py From boto3_type_annotations with MIT License | 5 votes |
def download_fileobj(self, Fileobj: IO = None, Key: str = None, ExtraArgs: Dict = None, Callback: Callable = None, Config: TransferConfig = None): pass
Example #18
Source File: s3.py From private-file-saver with MIT License | 5 votes |
def __init__(self, bucket_name=None): _credentials = { "aws_access_key_id": configs.AWS_ACCESS_KEY_ID, "aws_secret_access_key": configs.AWS_SECRET_ACCESS_KEY, "region_name": configs.AWS_REGION } self.bucket_name = bucket_name self.transfer_config = TransferConfig(multipart_threshold=configs.MULTIPART_THRESHOLD, max_concurrency=configs.MAX_CONCURRENCY, multipart_chunksize=configs.MULTIPART_CHUNKSIZE) self.s3 = boto3.resource('s3', **_credentials)
Example #19
Source File: test_minio.py From cjworkbench with GNU Affero General Public License v3.0 | 5 votes |
def test_assume_role_to_write_multipart(self): client = self._assume_role_session_client_with_write_access(Bucket, "key") from boto3.s3.transfer import TransferConfig data = b"1234567" * 1024 * 1024 # 7MB => 5MB+2MB parts client.upload_fileobj( io.BytesIO(data), Bucket, "key", Config=TransferConfig(multipart_threshold=5 * 1024 * 1024), ) self.assertEqual(minio.get_object_with_data(Bucket, "key")["Body"], data)
Example #20
Source File: inject.py From aws-extender with MIT License | 5 votes |
def object_download_fileobj(self, Fileobj, ExtraArgs=None, Callback=None, Config=None): """Download this object from S3 to a file-like object. The file-like object must be in binary mode. This is a managed transfer which will perform a multipart download in multiple threads if necessary. Usage:: import boto3 s3 = boto3.resource('s3') bucket = s3.Bucket('mybucket') obj = bucket.Object('mykey') with open('filename', 'wb') as data: obj.download_fileobj(data) :type Fileobj: a file-like object :param Fileobj: A file-like object to download into. At a minimum, it must implement the `write` method and must accept bytes. :type ExtraArgs: dict :param ExtraArgs: Extra arguments that may be passed to the client operation. :type Callback: method :param Callback: A method which takes a number of bytes transferred to be periodically called during the download. :type Config: boto3.s3.transfer.TransferConfig :param Config: The transfer configuration to be used when performing the download. """ return self.meta.client.download_fileobj( Bucket=self.bucket_name, Key=self.key, Fileobj=Fileobj, ExtraArgs=ExtraArgs, Callback=Callback, Config=Config)
Example #21
Source File: inject.py From aws-extender with MIT License | 5 votes |
def bucket_download_fileobj(self, Key, Fileobj, ExtraArgs=None, Callback=None, Config=None): """Download an object from this bucket to a file-like-object. The file-like object must be in binary mode. This is a managed transfer which will perform a multipart download in multiple threads if necessary. Usage:: import boto3 s3 = boto3.resource('s3') bucket = s3.Bucket('mybucket') with open('filename', 'wb') as data: bucket.download_fileobj('mykey', data) :type Fileobj: a file-like object :param Fileobj: A file-like object to download into. At a minimum, it must implement the `write` method and must accept bytes. :type Key: str :param Key: The name of the key to download from. :type ExtraArgs: dict :param ExtraArgs: Extra arguments that may be passed to the client operation. :type Callback: method :param Callback: A method which takes a number of bytes transferred to be periodically called during the download. :type Config: boto3.s3.transfer.TransferConfig :param Config: The transfer configuration to be used when performing the download. """ return self.meta.client.download_fileobj( Bucket=self.name, Key=Key, Fileobj=Fileobj, ExtraArgs=ExtraArgs, Callback=Callback, Config=Config)
Example #22
Source File: inject.py From aws-extender with MIT License | 5 votes |
def object_upload_fileobj(self, Fileobj, ExtraArgs=None, Callback=None, Config=None): """Upload a file-like object to this object. The file-like object must be in binary mode. This is a managed transfer which will perform a multipart upload in multiple threads if necessary. Usage:: import boto3 s3 = boto3.resource('s3') bucket = s3.Bucket('mybucket') obj = bucket.Object('mykey') with open('filename', 'rb') as data: obj.upload_fileobj(data) :type Fileobj: a file-like object :param Fileobj: A file-like object to upload. At a minimum, it must implement the `read` method, and must return bytes. :type ExtraArgs: dict :param ExtraArgs: Extra arguments that may be passed to the client operation. :type Callback: method :param Callback: A method which takes a number of bytes transferred to be periodically called during the upload. :type Config: boto3.s3.transfer.TransferConfig :param Config: The transfer configuration to be used when performing the upload. """ return self.meta.client.upload_fileobj( Fileobj=Fileobj, Bucket=self.bucket_name, Key=self.key, ExtraArgs=ExtraArgs, Callback=Callback, Config=Config)
Example #23
Source File: inject.py From aws-extender with MIT License | 5 votes |
def bucket_upload_fileobj(self, Fileobj, Key, ExtraArgs=None, Callback=None, Config=None): """Upload a file-like object to this bucket. The file-like object must be in binary mode. This is a managed transfer which will perform a multipart upload in multiple threads if necessary. Usage:: import boto3 s3 = boto3.resource('s3') bucket = s3.Bucket('mybucket') with open('filename', 'rb') as data: bucket.upload_fileobj(data, 'mykey') :type Fileobj: a file-like object :param Fileobj: A file-like object to upload. At a minimum, it must implement the `read` method, and must return bytes. :type Key: str :param Key: The name of the key to upload to. :type ExtraArgs: dict :param ExtraArgs: Extra arguments that may be passed to the client operation. :type Callback: method :param Callback: A method which takes a number of bytes transferred to be periodically called during the upload. :type Config: boto3.s3.transfer.TransferConfig :param Config: The transfer configuration to be used when performing the upload. """ return self.meta.client.upload_fileobj( Fileobj=Fileobj, Bucket=self.name, Key=Key, ExtraArgs=ExtraArgs, Callback=Callback, Config=Config)
Example #24
Source File: inject.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def object_download_fileobj(self, Fileobj, ExtraArgs=None, Callback=None, Config=None): """Download this object from S3 to a file-like object. The file-like object must be in binary mode. This is a managed transfer which will perform a multipart download in multiple threads if necessary. Usage:: import boto3 s3 = boto3.resource('s3') bucket = s3.Bucket('mybucket') obj = bucket.Object('mykey') with open('filename', 'wb') as data: obj.download_fileobj(data) :type Fileobj: a file-like object :param Fileobj: A file-like object to download into. At a minimum, it must implement the `write` method and must accept bytes. :type ExtraArgs: dict :param ExtraArgs: Extra arguments that may be passed to the client operation. :type Callback: function :param Callback: A method which takes a number of bytes transferred to be periodically called during the download. :type Config: boto3.s3.transfer.TransferConfig :param Config: The transfer configuration to be used when performing the download. """ return self.meta.client.download_fileobj( Bucket=self.bucket_name, Key=self.key, Fileobj=Fileobj, ExtraArgs=ExtraArgs, Callback=Callback, Config=Config)
Example #25
Source File: inject.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def bucket_download_fileobj(self, Key, Fileobj, ExtraArgs=None, Callback=None, Config=None): """Download an object from this bucket to a file-like-object. The file-like object must be in binary mode. This is a managed transfer which will perform a multipart download in multiple threads if necessary. Usage:: import boto3 s3 = boto3.resource('s3') bucket = s3.Bucket('mybucket') with open('filename', 'wb') as data: bucket.download_fileobj('mykey', data) :type Fileobj: a file-like object :param Fileobj: A file-like object to download into. At a minimum, it must implement the `write` method and must accept bytes. :type Key: str :param Key: The name of the key to download from. :type ExtraArgs: dict :param ExtraArgs: Extra arguments that may be passed to the client operation. :type Callback: function :param Callback: A method which takes a number of bytes transferred to be periodically called during the download. :type Config: boto3.s3.transfer.TransferConfig :param Config: The transfer configuration to be used when performing the download. """ return self.meta.client.download_fileobj( Bucket=self.name, Key=Key, Fileobj=Fileobj, ExtraArgs=ExtraArgs, Callback=Callback, Config=Config)
Example #26
Source File: inject.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def object_upload_fileobj(self, Fileobj, ExtraArgs=None, Callback=None, Config=None): """Upload a file-like object to this object. The file-like object must be in binary mode. This is a managed transfer which will perform a multipart upload in multiple threads if necessary. Usage:: import boto3 s3 = boto3.resource('s3') bucket = s3.Bucket('mybucket') obj = bucket.Object('mykey') with open('filename', 'rb') as data: obj.upload_fileobj(data) :type Fileobj: a file-like object :param Fileobj: A file-like object to upload. At a minimum, it must implement the `read` method, and must return bytes. :type ExtraArgs: dict :param ExtraArgs: Extra arguments that may be passed to the client operation. :type Callback: function :param Callback: A method which takes a number of bytes transferred to be periodically called during the upload. :type Config: boto3.s3.transfer.TransferConfig :param Config: The transfer configuration to be used when performing the upload. """ return self.meta.client.upload_fileobj( Fileobj=Fileobj, Bucket=self.bucket_name, Key=self.key, ExtraArgs=ExtraArgs, Callback=Callback, Config=Config)
Example #27
Source File: inject.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def object_upload_file(self, Filename, ExtraArgs=None, Callback=None, Config=None): """Upload a file to an S3 object. Usage:: import boto3 s3 = boto3.resource('s3') s3.Object('mybucket', 'hello.txt').upload_file('/tmp/hello.txt') Similar behavior as S3Transfer's upload_file() method, except that parameters are capitalized. Detailed examples can be found at :ref:`S3Transfer's Usage <ref_s3transfer_usage>`. :type Filename: str :param Filename: The path to the file to upload. :type ExtraArgs: dict :param ExtraArgs: Extra arguments that may be passed to the client operation. :type Callback: function :param Callback: A method which takes a number of bytes transferred to be periodically called during the upload. :type Config: boto3.s3.transfer.TransferConfig :param Config: The transfer configuration to be used when performing the transfer. """ return self.meta.client.upload_file( Filename=Filename, Bucket=self.bucket_name, Key=self.key, ExtraArgs=ExtraArgs, Callback=Callback, Config=Config)
Example #28
Source File: inject.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def bucket_upload_file(self, Filename, Key, ExtraArgs=None, Callback=None, Config=None): """Upload a file to an S3 object. Usage:: import boto3 s3 = boto3.resource('s3') s3.Bucket('mybucket').upload_file('/tmp/hello.txt', 'hello.txt') Similar behavior as S3Transfer's upload_file() method, except that parameters are capitalized. Detailed examples can be found at :ref:`S3Transfer's Usage <ref_s3transfer_usage>`. :type Filename: str :param Filename: The path to the file to upload. :type Key: str :param Key: The name of the key to upload to. :type ExtraArgs: dict :param ExtraArgs: Extra arguments that may be passed to the client operation. :type Callback: function :param Callback: A method which takes a number of bytes transferred to be periodically called during the upload. :type Config: boto3.s3.transfer.TransferConfig :param Config: The transfer configuration to be used when performing the transfer. """ return self.meta.client.upload_file( Filename=Filename, Bucket=self.name, Key=Key, ExtraArgs=ExtraArgs, Callback=Callback, Config=Config)
Example #29
Source File: inject.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def download_file(self, Bucket, Key, Filename, ExtraArgs=None, Callback=None, Config=None): """Download an S3 object to a file. Usage:: import boto3 s3 = boto3.resource('s3') s3.meta.client.download_file('mybucket', 'hello.txt', '/tmp/hello.txt') Similar behavior as S3Transfer's download_file() method, except that parameters are capitalized. Detailed examples can be found at :ref:`S3Transfer's Usage <ref_s3transfer_usage>`. :type Filename: str :param Filename: The path to the file to download to. :type Bucket: str :param Bucket: The name of the bucket to download from. :type Key: str :param Key: The name of the key to download from. :type ExtraArgs: dict :param ExtraArgs: Extra arguments that may be passed to the client operation. :type Callback: function :param Callback: A method which takes a number of bytes transferred to be periodically called during the download. :type Config: boto3.s3.transfer.TransferConfig :param Config: The transfer configuration to be used when performing the transfer. """ with S3Transfer(self, Config) as transfer: return transfer.download_file( bucket=Bucket, key=Key, filename=Filename, extra_args=ExtraArgs, callback=Callback)
Example #30
Source File: inject.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def upload_file(self, Filename, Bucket, Key, ExtraArgs=None, Callback=None, Config=None): """Upload a file to an S3 object. Usage:: import boto3 s3 = boto3.resource('s3') s3.meta.client.upload_file('/tmp/hello.txt', 'mybucket', 'hello.txt') Similar behavior as S3Transfer's upload_file() method, except that parameters are capitalized. Detailed examples can be found at :ref:`S3Transfer's Usage <ref_s3transfer_usage>`. :type Filename: str :param Filename: The path to the file to upload. :type Bucket: str :param Bucket: The name of the bucket to upload to. :type Key: str :param Key: The name of the key to upload to. :type ExtraArgs: dict :param ExtraArgs: Extra arguments that may be passed to the client operation. :type Callback: function :param Callback: A method which takes a number of bytes transferred to be periodically called during the upload. :type Config: boto3.s3.transfer.TransferConfig :param Config: The transfer configuration to be used when performing the transfer. """ with S3Transfer(self, Config) as transfer: return transfer.upload_file( filename=Filename, bucket=Bucket, key=Key, extra_args=ExtraArgs, callback=Callback)