class_docstr: The ``MultipartEncoder`` object is a generic interface to the engine that
  will create a ``multipart/form-data`` body for you.
  
  The basic usage is:
  
  .. code-block:: py
  
      import requests
      from requests_toolbelt import MultipartEncoder
  
      encoder = MultipartEncoder({'field': 'value',
                                  'other_field': 'other_value'})
      r = requests.post('https://httpbin.org/post', data=encoder,
                        headers={'Content-Type': encoder.content_type})
  
  If you do not need to take advantage of streaming the post body, you can
  also do:
  
  .. code-block:: py
  
      r = requests.post('https://httpbin.org/post',
                        data=encoder.to_string(),
                        headers={'Content-Type': encoder.content_type})
  
  If you want the encoder to use a specific order, you can use an
  OrderedDict or more simply, a list of tuples:
  
  .. code-block:: py
  
      encoder = MultipartEncoder([('field', 'value'),
                                  ('other_field', 'other_value')])
  
  .. versionchanged:: 0.4.0
  
  You can also provide tuples as part values as you would provide them to
  requests' ``files`` parameter.
  
  .. code-block:: py
  
      encoder = MultipartEncoder({
          'field': ('file_name', b'{"a": "b"}', 'application/json',
                    {'X-My-Header': 'my-value'})
      ])
  
  .. warning::
  
      This object will end up directly in :mod:`httplib`. Currently,
      :mod:`httplib` has a hard-coded read size of **8192 bytes**. This
      means that it will loop until the file has been read and your upload
      could take a while. This is **not** a bug in requests. A feature is
      being considered for this object to allow you, the user, to specify
      what size should be returned on a read. If you have opinions on this,
      please weigh in on `this issue`_.
  
  .. _this issue:
      https://github.com/requests/toolbelt/issues/75
class_docstr_tok: ["The","``","MultipartEncoder","``","object","is","a","generic","interface","to","the","engine","that","will","create","a","``","multipart\/form-data","``","body","for","you",".","The","basic","usage","is",":","..","code-block",":",":","py","import","requests","from","requests_toolbelt","import","MultipartEncoder","encoder","=","MultipartEncoder","(","{","'field","'",":","'value","'",",","'other_field","'",":","'other_value","'","}",")","r","=","requests.post","(","'https",":","\/\/httpbin.org\/post","'",",","data=encoder",",","headers=","{","'Content-Type","'",":","encoder.content_type","}",")","If","you","do","not","need","to","take","advantage","of","streaming","the","post","body",",","you","can","also","do",":","..","code-block",":",":","py","r","=","requests.post","(","'https",":","\/\/httpbin.org\/post","'",",","data=encoder.to_string","(",")",",","headers=","{","'Content-Type","'",":","encoder.content_type","}",")","If","you","want","the","encoder","to","use","a","specific","order",",","you","can","use","an","OrderedDict","or","more","simply",",","a","list","of","tuples",":","..","code-block",":",":","py","encoder","=","MultipartEncoder","(","[","(","'field","'",",","'value","'",")",",","(","'other_field","'",",","'other_value","'",")","]",")","..","versionchanged",":",":","0.4.0","You","can","also","provide","tuples","as","part","values","as","you","would","provide","them","to","requests","'","``","files","``","parameter",".","..","code-block",":",":","py","encoder","=","MultipartEncoder","(","{","'field","'",":","(","'file_name","'",",","b","'","{","``","a","''",":","``","b","''","}","'",",","'application\/json","'",",","{","'","X-My-Header","'",":","'my-value","'","}",")","]",")","..","warning",":",":","This","object","will","end","up","directly","in",":","mod",":","`","httplib","`",".","Currently",",",":","mod",":","`","httplib","`","has","a","hard-coded","read","size","of","*","*","8192","bytes","*","*",".","This","means","that","it","will","loop","until","the","file","has","been","read","and","your","upload","could","take","a","while",".","This","is","*","*","not","*","*","a","bug","in","requests",".","A","feature","is","being","considered","for","this","object","to","allow","you",",","the","user",",","to","specify","what","size","should","be","returned","on","a","read",".","If","you","have","opinions","on","this",",","please","weigh","in","on","`","this","issue","`","_",".","..","_this","issue",":","https",":","\/\/github.com\/requests\/toolbelt\/issues\/75"]
docstr: Length of the multipart/form-data body.
  
  requests will first attempt to get the length of the body by calling
  ``len(body)`` and then by checking for the ``len`` attribute.
  
  On 32-bit systems, the ``__len__`` method cannot return anything
  larger than an integer (in C) can hold. If the total size of the body
  is even slightly larger than 4GB users will see an OverflowError. This
  manifested itself in `bug #80`_.
  
  As such, we now calculate the length lazily as a property.
  
  .. _bug #80:
      https://github.com/requests/toolbelt/issues/80
code: def len(self):
      """Length of the multipart/form-data body.
  
      requests will first attempt to get the length of the body by calling
      ``len(body)`` and then by checking for the ``len`` attribute.
  
      On 32-bit systems, the ``__len__`` method cannot return anything
      larger than an integer (in C) can hold. If the total size of the body
      is even slightly larger than 4GB users will see an OverflowError. This
      manifested itself in `bug #80`_.
  
      As such, we now calculate the length lazily as a property.
  
      .. _bug #80:
          https://github.com/requests/toolbelt/issues/80
      """
      # If _len isn't already calculated, calculate, return, and set it
      return self._len or self._calculate_length()
  
imports: import contextlib
  import io
  import os
  from uuid import uuid4
  import requests
  from .._compat import fields
label_desc: Use image node_id 2 for calling the MultipartEncoder obj's underlying member method code with example usage: obj.len() and returns: unknown