{
    "mode": "pydoc",
    "parameter": "s3transfer",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/s3transfer/json",
    "generated": "2026-06-02T14:23:06Z",
    "sections": {
        "NAME": {
            "content": "s3transfer - Abstractions over S3's upload/download operations.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module provides high level abstractions for efficient\nuploads/downloads.  It handles several things for the user:\n\n* Automatically switching to multipart transfers when\na file is over a specific size threshold\n* Uploading/downloading a file in parallel\n* Throttling based on max bandwidth\n* Progress callbacks to monitor transfers\n* Retries.  While botocore handles retries for streaming uploads,\nit is not possible for it to handle retries for streaming\ndownloads.  This module handles retries for both cases so\nyou don't need to implement any retry logic yourself.\n\nThis module has a reasonable set of defaults.  It also allows you\nto configure many aspects of the transfer process including:\n\n* Multipart threshold size\n* Max parallel downloads\n* Max bandwidth\n* Socket timeouts\n* Retry amounts\n\nThere is no support for s3->s3 multipart copies at this\ntime.\n\n\n.. refs3transferusage:\n\nUsage\n=====\n\nThe simplest way to use this module is:\n\n.. code-block:: python\n\nclient = boto3.client('s3', 'us-west-2')\ntransfer = S3Transfer(client)\n# Upload /tmp/myfile to s3://bucket/key\ntransfer.uploadfile('/tmp/myfile', 'bucket', 'key')\n\n# Download s3://bucket/key to /tmp/myfile\ntransfer.downloadfile('bucket', 'key', '/tmp/myfile')\n\nThe ``uploadfile`` and ``downloadfile`` methods also accept\n``kwargs``, which will be forwarded through to the corresponding\nclient operation.  Here are a few examples using ``uploadfile``::\n\n# Making the object public\ntransfer.uploadfile('/tmp/myfile', 'bucket', 'key',\nextraargs={'ACL': 'public-read'})\n\n# Setting metadata\ntransfer.uploadfile('/tmp/myfile', 'bucket', 'key',\nextraargs={'Metadata': {'a': 'b', 'c': 'd'}})\n\n# Setting content type\ntransfer.uploadfile('/tmp/myfile.json', 'bucket', 'key',\nextraargs={'ContentType': \"application/json\"})\n\n\nThe ``S3Transfer`` clas also supports progress callbacks so you can\nprovide transfer progress to users.  Both the ``uploadfile`` and\n``downloadfile`` methods take an optional ``callback`` parameter.\nHere's an example of how to print a simple progress percentage\nto the user:\n\n.. code-block:: python\n\nclass ProgressPercentage(object):\ndef init(self, filename):\nself.filename = filename\nself.size = float(os.path.getsize(filename))\nself.seensofar = 0\nself.lock = threading.Lock()\n\ndef call(self, bytesamount):\n# To simplify we'll assume this is hooked up\n# to a single filename.\nwith self.lock:\nself.seensofar += bytesamount\npercentage = (self.seensofar / self.size) * 100\nsys.stdout.write(\n\"\r%s  %s / %s  (%.2f%%)\" % (self.filename, self.seensofar,\nself.size, percentage))\nsys.stdout.flush()\n\n\ntransfer = S3Transfer(boto3.client('s3', 'us-west-2'))\n# Upload /tmp/myfile to s3://bucket/key and print upload progress.\ntransfer.uploadfile('/tmp/myfile', 'bucket', 'key',\ncallback=ProgressPercentage('/tmp/myfile'))\n\n\n\nYou can also provide a TransferConfig object to the S3Transfer\nobject that gives you more fine grained control over the\ntransfer.  For example:\n\n.. code-block:: python\n\nclient = boto3.client('s3', 'us-west-2')\nconfig = TransferConfig(\nmultipartthreshold=8 * 1024 * 1024,\nmaxconcurrency=10,\nnumdownloadattempts=10,\n)\ntransfer = S3Transfer(client, config)\ntransfer.uploadfile('/tmp/foo', 'bucket', 'key')\n",
            "subsections": []
        },
        "PACKAGE CONTENTS": {
            "content": "bandwidth\ncompat\nconstants\ncopies\ncrt\ndelete\ndownload\nexceptions\nfutures\nmanager\nprocesspool\nsubscribers\ntasks\nupload\nutils\n",
            "subsections": []
        },
        "CLASSES": {
            "content": "builtins.Exception(builtins.BaseException)\nQueueShutdownError\nbuiltins.object\nMultipartDownloader\nMultipartUploader\nOSUtils\nReadFileChunk\nS3Transfer\nStreamReaderProgress\nTransferConfig\nlogging.Handler(logging.Filterer)\nNullHandler\nqueue.Queue(builtins.object)\nShutdownQueue\n",
            "subsections": [
                {
                    "name": "class MultipartDownloader",
                    "content": "|  MultipartDownloader(client, config, osutil, executorcls=<class 'concurrent.futures.thread.ThreadPoolExecutor'>)\n|\n|  Methods defined here:\n|\n|  init(self, client, config, osutil, executorcls=<class 'concurrent.futures.thread.ThreadPoolExecutor'>)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  downloadfile(self, bucket, key, filename, objectsize, extraargs, callback=None)\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class MultipartUploader",
                    "content": "|  MultipartUploader(client, config, osutil, executorcls=<class 'concurrent.futures.thread.ThreadPoolExecutor'>)\n|\n|  Methods defined here:\n|\n|  init(self, client, config, osutil, executorcls=<class 'concurrent.futures.thread.ThreadPoolExecutor'>)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  uploadfile(self, filename, bucket, key, callback, extraargs)\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  UPLOADPARTARGS = ['SSECustomerKey', 'SSECustomerAlgorithm', 'SSECust...\n"
                },
                {
                    "name": "class NullHandler",
                    "content": "|  NullHandler(level=0)\n|\n|  Method resolution order:\n|      NullHandler\n|      logging.Handler\n|      logging.Filterer\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  emit(self, record)\n|      Do whatever it takes to actually log the specified logging record.\n|\n|      This version is intended to be implemented by subclasses and so\n|      raises a NotImplementedError.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from logging.Handler:\n|\n|  init(self, level=0)\n|      Initializes the instance - basically setting the formatter to None\n|      and the filter list to empty.\n|\n|  repr(self)\n|      Return repr(self).\n|\n|  acquire(self)\n|      Acquire the I/O thread lock.\n|\n|  close(self)\n|      Tidy up any resources used by the handler.\n|\n|      This version removes the handler from an internal map of handlers,\n|      handlers, which is used for handler lookup by name. Subclasses\n|      should ensure that this gets called from overridden close()\n|      methods.\n|\n|  createLock(self)\n|      Acquire a thread lock for serializing access to the underlying I/O.\n|\n|  flush(self)\n|      Ensure all logging output has been flushed.\n|\n|      This version does nothing and is intended to be implemented by\n|      subclasses.\n|\n|  format(self, record)\n|      Format the specified record.\n|\n|      If a formatter is set, use it. Otherwise, use the default formatter\n|      for the module.\n|\n|  getname(self)\n|\n|  handle(self, record)\n|      Conditionally emit the specified logging record.\n|\n|      Emission depends on filters which may have been added to the handler.\n|      Wrap the actual emission of the record with acquisition/release of\n|      the I/O thread lock. Returns whether the filter passed the record for\n|      emission.\n|\n|  handleError(self, record)\n|      Handle errors which occur during an emit() call.\n|\n|      This method should be called from handlers when an exception is\n|      encountered during an emit() call. If raiseExceptions is false,\n|      exceptions get silently ignored. This is what is mostly wanted\n|      for a logging system - most users will not care about errors in\n|      the logging system, they are more interested in application errors.\n|      You could, however, replace this with a custom handler if you wish.\n|      The record which was being processed is passed in to this method.\n|\n|  release(self)\n|      Release the I/O thread lock.\n|\n|  setFormatter(self, fmt)\n|      Set the formatter for this handler.\n|\n|  setLevel(self, level)\n|      Set the logging level of this handler.  level must be an int or a str.\n|\n|  setname(self, name)\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from logging.Handler:\n|\n|  name\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from logging.Filterer:\n|\n|  addFilter(self, filter)\n|      Add the specified filter to this handler.\n|\n|  filter(self, record)\n|      Determine if a record is loggable by consulting all the filters.\n|\n|      The default is to allow the record to be logged; any filter can veto\n|      this and the record is then dropped. Returns a zero value if a record\n|      is to be dropped, else non-zero.\n|\n|      .. versionchanged:: 3.2\n|\n|         Allow filters to be just callables.\n|\n|  removeFilter(self, filter)\n|      Remove the specified filter from this handler.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from logging.Filterer:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class OSUtils",
                    "content": "|  Methods defined here:\n|\n|  getfilesize(self, filename)\n|\n|  open(self, filename, mode)\n|\n|  openfilechunkreader(self, filename, startbyte, size, callback)\n|\n|  removefile(self, filename)\n|      Remove a file, noop if file does not exist.\n|\n|  renamefile(self, currentfilename, newfilename)\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class QueueShutdownError",
                    "content": "|  Method resolution order:\n|      QueueShutdownError\n|      builtins.Exception\n|      builtins.BaseException\n|      builtins.object\n|\n|  Data descriptors defined here:\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.Exception:\n|\n|  init(self, /, *args, kwargs)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from builtins.Exception:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.BaseException:\n|\n|  delattr(self, name, /)\n|      Implement delattr(self, name).\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  reduce(...)\n|      Helper for pickle.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  setattr(self, name, value, /)\n|      Implement setattr(self, name, value).\n|\n|  setstate(...)\n|\n|  str(self, /)\n|      Return str(self).\n|\n|  withtraceback(...)\n|      Exception.withtraceback(tb) --\n|      set self.traceback to tb and return self.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from builtins.BaseException:\n|\n|  cause\n|      exception cause\n|\n|  context\n|      exception context\n|\n|  dict\n|\n|  suppresscontext\n|\n|  traceback\n|\n|  args\n"
                },
                {
                    "name": "class ReadFileChunk",
                    "content": "|  ReadFileChunk(fileobj, startbyte, chunksize, fullfilesize, callback=None, enablecallback=True)\n|\n|  Methods defined here:\n|\n|  enter(self)\n|\n|  exit(self, *args, kwargs)\n|\n|  init(self, fileobj, startbyte, chunksize, fullfilesize, callback=None, enablecallback=True)\n|      Given a file object shown below:\n|\n|          ||\n|          0          |                 |                 fullfilesize\n|                     |----chunksize---|\n|               startbyte\n|\n|      :type fileobj: file\n|      :param fileobj: File like object\n|\n|      :type startbyte: int\n|      :param startbyte: The first byte from which to start reading.\n|\n|      :type chunksize: int\n|      :param chunksize: The max chunk size to read.  Trying to read\n|          pass the end of the chunk size will behave like you've\n|          reached the end of the file.\n|\n|      :type fullfilesize: int\n|      :param fullfilesize: The entire content length associated\n|          with ``fileobj``.\n|\n|      :type callback: function(amountread)\n|      :param callback: Called whenever data is read from this object.\n|\n|  iter(self)\n|\n|  len(self)\n|\n|  close(self)\n|\n|  disablecallback(self)\n|\n|  enablecallback(self)\n|\n|  read(self, amount=None)\n|\n|  seek(self, where)\n|\n|  tell(self)\n|\n|  ----------------------------------------------------------------------\n|  Class methods defined here:\n|\n|  fromfilename(filename, startbyte, chunksize, callback=None, enablecallback=True) from builtins.type\n|      Convenience factory function to create from a filename.\n|\n|      :type startbyte: int\n|      :param startbyte: The first byte from which to start reading.\n|\n|      :type chunksize: int\n|      :param chunksize: The max chunk size to read.  Trying to read\n|          pass the end of the chunk size will behave like you've\n|          reached the end of the file.\n|\n|      :type fullfilesize: int\n|      :param fullfilesize: The entire content length associated\n|          with ``fileobj``.\n|\n|      :type callback: function(amountread)\n|      :param callback: Called whenever data is read from this object.\n|\n|      :type enablecallback: bool\n|      :param enablecallback: Indicate whether to invoke callback\n|          during read() calls.\n|\n|      :rtype: ``ReadFileChunk``\n|      :return: A new instance of ``ReadFileChunk``\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class S3Transfer",
                    "content": "|  S3Transfer(client, config=None, osutil=None)\n|\n|  Methods defined here:\n|\n|  init(self, client, config=None, osutil=None)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  downloadfile(self, bucket, key, filename, extraargs=None, callback=None)\n|      Download an S3 object to a file.\n|\n|      Variants have also been injected into S3 client, Bucket and Object.\n|      You don't have to use S3Transfer.downloadfile() directly.\n|\n|  uploadfile(self, filename, bucket, key, callback=None, extraargs=None)\n|      Upload a file to an S3 object.\n|\n|      Variants have also been injected into S3 client, Bucket and Object.\n|      You don't have to use S3Transfer.uploadfile() directly.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  ALLOWEDDOWNLOADARGS = ['VersionId', 'SSECustomerAlgorithm', 'SSECust...\n|\n|  ALLOWEDUPLOADARGS = ['ACL', 'CacheControl', 'ContentDisposition', 'C...\n"
                },
                {
                    "name": "class ShutdownQueue",
                    "content": "|  ShutdownQueue(maxsize=0)\n|\n|  A queue implementation that can be shutdown.\n|\n|  Shutting down a queue means that this class adds a\n|  triggershutdown method that will trigger all subsequent\n|  calls to put() to fail with a ``QueueShutdownError``.\n|\n|  It purposefully deviates from queue.Queue, and is *not* meant\n|  to be a drop in replacement for ``queue.Queue``.\n|\n|  Method resolution order:\n|      ShutdownQueue\n|      queue.Queue\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  put(self, item)\n|      Put an item into the queue.\n|\n|      If optional args 'block' is true and 'timeout' is None (the default),\n|      block if necessary until a free slot is available. If 'timeout' is\n|      a non-negative number, it blocks at most 'timeout' seconds and raises\n|      the Full exception if no free slot was available within that time.\n|      Otherwise ('block' is false), put an item on the queue if a free slot\n|      is immediately available, else raise the Full exception ('timeout'\n|      is ignored in that case).\n|\n|  triggershutdown(self)\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from queue.Queue:\n|\n|  init(self, maxsize=0)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  empty(self)\n|      Return True if the queue is empty, False otherwise (not reliable!).\n|\n|      This method is likely to be removed at some point.  Use qsize() == 0\n|      as a direct substitute, but be aware that either approach risks a race\n|      condition where a queue can grow before the result of empty() or\n|      qsize() can be used.\n|\n|      To create code that needs to wait for all queued tasks to be\n|      completed, the preferred technique is to use the join() method.\n|\n|  full(self)\n|      Return True if the queue is full, False otherwise (not reliable!).\n|\n|      This method is likely to be removed at some point.  Use qsize() >= n\n|      as a direct substitute, but be aware that either approach risks a race\n|      condition where a queue can shrink before the result of full() or\n|      qsize() can be used.\n|\n|  get(self, block=True, timeout=None)\n|      Remove and return an item from the queue.\n|\n|      If optional args 'block' is true and 'timeout' is None (the default),\n|      block if necessary until an item is available. If 'timeout' is\n|      a non-negative number, it blocks at most 'timeout' seconds and raises\n|      the Empty exception if no item was available within that time.\n|      Otherwise ('block' is false), return an item if one is immediately\n|      available, else raise the Empty exception ('timeout' is ignored\n|      in that case).\n|\n|  getnowait(self)\n|      Remove and return an item from the queue without blocking.\n|\n|      Only get an item if one is immediately available. Otherwise\n|      raise the Empty exception.\n|\n|  join(self)\n|      Blocks until all items in the Queue have been gotten and processed.\n|\n|      The count of unfinished tasks goes up whenever an item is added to the\n|      queue. The count goes down whenever a consumer thread calls taskdone()\n|      to indicate the item was retrieved and all work on it is complete.\n|\n|      When the count of unfinished tasks drops to zero, join() unblocks.\n|\n|  putnowait(self, item)\n|      Put an item into the queue without blocking.\n|\n|      Only enqueue the item if a free slot is immediately available.\n|      Otherwise raise the Full exception.\n|\n|  qsize(self)\n|      Return the approximate size of the queue (not reliable!).\n|\n|  taskdone(self)\n|      Indicate that a formerly enqueued task is complete.\n|\n|      Used by Queue consumer threads.  For each get() used to fetch a task,\n|      a subsequent call to taskdone() tells the queue that the processing\n|      on the task is complete.\n|\n|      If a join() is currently blocking, it will resume when all items\n|      have been processed (meaning that a taskdone() call was received\n|      for every item that had been put() into the queue).\n|\n|      Raises a ValueError if called more times than there were items\n|      placed in the queue.\n|\n|  ----------------------------------------------------------------------\n|  Class methods inherited from queue.Queue:\n|\n|  classgetitem = GenericAlias(...) from builtins.type\n|      Represent a PEP 585 generic type\n|\n|      E.g. for t = list[int], t.origin is list and t.args is (int,).\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from queue.Queue:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class StreamReaderProgress",
                    "content": "|  StreamReaderProgress(stream, callback=None)\n|\n|  Wrapper for a read only stream that adds progress callbacks.\n|\n|  Methods defined here:\n|\n|  init(self, stream, callback=None)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  read(self, *args, kwargs)\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class TransferConfig",
                    "content": "|  TransferConfig(multipartthreshold=8388608, maxconcurrency=10, multipartchunksize=8388608, numdownloadattempts=5, maxioqueue=100)\n|\n|  Methods defined here:\n|\n|  init(self, multipartthreshold=8388608, maxconcurrency=10, multipartchunksize=8388608, numdownloadattempts=5, maxioqueue=100)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                }
            ]
        },
        "FUNCTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "disable_upload_callbacks",
                    "content": ""
                },
                {
                    "name": "enable_upload_callbacks",
                    "content": ""
                },
                {
                    "name": "random_file_extension",
                    "content": ""
                }
            ]
        },
        "DATA": {
            "content": "MB = 1048576\nSHUTDOWNSENTINEL = <object object>\nlogger = <Logger s3transfer (WARNING)>\n",
            "subsections": []
        },
        "VERSION": {
            "content": "0.5.0\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Amazon Web Services\n",
            "subsections": []
        },
        "FILE": {
            "content": "/usr/lib/python3/dist-packages/s3transfer/init.py\n\n",
            "subsections": []
        }
    },
    "summary": "s3transfer - Abstractions over S3's upload/download operations.",
    "flags": [],
    "examples": [],
    "see_also": []
}