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: This calculates how many bytes need to be added to the buffer.
  
  When a consumer read's ``x`` from the buffer, there are two cases to
  satisfy:
  
      1. Enough data in the buffer to return the requested amount
      2. Not enough data
  
  This function uses the amount of unread bytes in the buffer and
  determines how much the Encoder has to load before it can return the
  requested amount of bytes.
  
  :param int read_size: the number of bytes the consumer requests
  :returns: int -- the number of bytes that must be loaded into the
      buffer before the read can be satisfied. This will be strictly
      non-negative
code: def _calculate_load_amount(self, read_size):
      """This calculates how many bytes need to be added to the buffer.
  
      When a consumer read's ``x`` from the buffer, there are two cases to
      satisfy:
  
          1. Enough data in the buffer to return the requested amount
          2. Not enough data
  
      This function uses the amount of unread bytes in the buffer and
      determines how much the Encoder has to load before it can return the
      requested amount of bytes.
  
      :param int read_size: the number of bytes the consumer requests
      :returns: int -- the number of bytes that must be loaded into the
          buffer before the read can be satisfied. This will be strictly
          non-negative
      """
      amount = read_size - total_len(self._buffer)
      return amount if amount > 0 else 0
  
imports: import contextlib
  import io
  import os
  from uuid import uuid4
  import requests
  from .._compat import fields
label_desc: Use image node_id 5 for calling the MultipartEncoder obj's underlying member method code with example usage: obj._calculate_load_amount(read_size) and returns: unknown