title: python requests send string as file
body: <p>In my code I am currently chunking up a file and sending reading it into a temporary file, then passing this temporary file into requests. Is there a way to still send this </p>
  
  <pre><code>with open(full_path, 'r+b') as f:
    i=0
    while True:
    chunk = f.read(max_chunk_size)
    if not chunk:
      break
    with tempfile.TemporaryFile() as t:
      t.write(chunk)
      t.seek(0)
      r = requests.post(endpoint + 'upload_chunk',
                        files={'chunk':t},
                        data={'mod_time':file_update_time,
                              'directory':'/'.join(subdirs),
                              'filename':filename,
                              'chunk_pos':i},
                        auth=auth)
      i+=max_chunk_size
  </code></pre>
  
  <p>Is there a way to send the chunk to the server without writing it to a temporary file, then having something in requests.post read this file? I'd much prefer to not have to change the server-side code. I'd imagine not having to read/write an extra 4 megabytes would increase execution speed.</p>
  
  <p>Chunking up the file is necessary; this code is not yet complete.</p>