當前位置: 首頁>>代碼示例>>Python>>正文


Python transfer.create_transfer_manager方法代碼示例

本文整理匯總了Python中boto3.s3.transfer.create_transfer_manager方法的典型用法代碼示例。如果您正苦於以下問題:Python transfer.create_transfer_manager方法的具體用法?Python transfer.create_transfer_manager怎麽用?Python transfer.create_transfer_manager使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在boto3.s3.transfer的用法示例。


在下文中一共展示了transfer.create_transfer_manager方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from boto3.s3 import transfer [as 別名]
# 或者: from boto3.s3.transfer import create_transfer_manager [as 別名]
def main():

    if os.environ.get('DDTRACE_EXTRA_PATCH') == 'true':
        # The ddtrace/Django integration only patches Django internals, it
        # doesn't patch other libraries.
        # Manually patching them very early here seems like a less intrusive
        # approach than running the whole app under `ddtrace-run`
        import ddtrace
        ddtrace.patch(requests=True, botocore=True, redis=True)

    # Dirty Monkey Patch to prevent boto3 from creating many threadpools
    try:
        from boto3.s3 import transfer
    except ImportError:
        pass
    else:
        def create_transfer_manager(*arg, **kwargs):
            return transfer.TransferManager(
                *arg, **kwargs, executor_cls=transfer.NonThreadedExecutor
            )
        transfer.create_transfer_manager = create_transfer_manager

    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "feedsubs.settings.dev")
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv) 
開發者ID:NicolasLM,項目名稱:feedsubs,代碼行數:34,代碼來源:manage.py

示例2: upload_fileobj

# 需要導入模塊: from boto3.s3 import transfer [as 別名]
# 或者: from boto3.s3.transfer import create_transfer_manager [as 別名]
def upload_fileobj(self, Fileobj, Bucket, Key, ExtraArgs=None,
                   Callback=None, Config=None):
    """Upload a file-like object to S3.

    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.client('s3')

        with open('filename', 'rb') as data:
            s3.upload_fileobj(data, 'mybucket', '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 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: 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.
    """
    if not hasattr(Fileobj, 'read'):
        raise ValueError('Fileobj must implement read')

    subscribers = None
    if Callback is not None:
        subscribers = [ProgressCallbackInvoker(Callback)]

    config = Config
    if config is None:
        config = TransferConfig()

    with create_transfer_manager(self, config) as manager:
        future = manager.upload(
            fileobj=Fileobj, bucket=Bucket, key=Key,
            extra_args=ExtraArgs, subscribers=subscribers)
        return future.result() 
開發者ID:skarlekar,項目名稱:faces,代碼行數:57,代碼來源:inject.py

示例3: download_fileobj

# 需要導入模塊: from boto3.s3 import transfer [as 別名]
# 或者: from boto3.s3.transfer import create_transfer_manager [as 別名]
def download_fileobj(self, Bucket, Key, Fileobj, ExtraArgs=None,
                     Callback=None, Config=None):
    """Download an 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.client('s3')

        with open('filename', 'wb') as data:
            s3.download_fileobj('mybucket', '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 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: 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.
    """
    if not hasattr(Fileobj, 'write'):
        raise ValueError('Fileobj must implement write')

    subscribers = None
    if Callback is not None:
        subscribers = [ProgressCallbackInvoker(Callback)]

    config = Config
    if config is None:
        config = TransferConfig()

    with create_transfer_manager(self, config) as manager:
        future = manager.download(
            bucket=Bucket, key=Key, fileobj=Fileobj,
            extra_args=ExtraArgs, subscribers=subscribers)
        return future.result() 
開發者ID:skarlekar,項目名稱:faces,代碼行數:57,代碼來源:inject.py

示例4: upload_fileobj

# 需要導入模塊: from boto3.s3 import transfer [as 別名]
# 或者: from boto3.s3.transfer import create_transfer_manager [as 別名]
def upload_fileobj(self, Fileobj, Bucket, Key, ExtraArgs=None,
                   Callback=None, Config=None):
    """Upload a file-like object to S3.

    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.client('s3')

        with open('filename', 'rb') as data:
            s3.upload_fileobj(data, 'mybucket', '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 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
        upload.
    """
    if not hasattr(Fileobj, 'read'):
        raise ValueError('Fileobj must implement read')

    subscribers = None
    if Callback is not None:
        subscribers = [ProgressCallbackInvoker(Callback)]

    config = Config
    if config is None:
        config = TransferConfig()

    with create_transfer_manager(self, config) as manager:
        future = manager.upload(
            fileobj=Fileobj, bucket=Bucket, key=Key,
            extra_args=ExtraArgs, subscribers=subscribers)
        return future.result() 
開發者ID:MattTunny,項目名稱:AWS-Transit-Gateway-Demo-MultiAccount,代碼行數:57,代碼來源:inject.py

示例5: download_fileobj

# 需要導入模塊: from boto3.s3 import transfer [as 別名]
# 或者: from boto3.s3.transfer import create_transfer_manager [as 別名]
def download_fileobj(self, Bucket, Key, Fileobj, ExtraArgs=None,
                     Callback=None, Config=None):
    """Download an 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.client('s3')

        with open('filename', 'wb') as data:
            s3.download_fileobj('mybucket', '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 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
        download.
    """
    if not hasattr(Fileobj, 'write'):
        raise ValueError('Fileobj must implement write')

    subscribers = None
    if Callback is not None:
        subscribers = [ProgressCallbackInvoker(Callback)]

    config = Config
    if config is None:
        config = TransferConfig()

    with create_transfer_manager(self, config) as manager:
        future = manager.download(
            bucket=Bucket, key=Key, fileobj=Fileobj,
            extra_args=ExtraArgs, subscribers=subscribers)
        return future.result() 
開發者ID:MattTunny,項目名稱:AWS-Transit-Gateway-Demo-MultiAccount,代碼行數:57,代碼來源:inject.py


注:本文中的boto3.s3.transfer.create_transfer_manager方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。