title: Python3 Flask open uploaded files without saving
body: <p>I am using flask as a webserver, my goal is to upload a pdf file to my server and then send  the uploaded from my server to another url.</p>
  <p>My current solution is to save the file on my server first before sending it to the third party endpoint, this is however a constraint for me because I don't want to save the files on my server.</p>
  <pre><code>import os
  import requests
  from flask import Flask, request, jsonify
  from werkzeug.utils import secure_filename
  
  app = Flask(__name__)
  
  URL = &quot;http://www.example.com&quot;
  UPLOAD_FOLDER = &quot;/path/to/upload/folder&quot;
  
  @app.post(&quot;/&quot;)
  def upload_file():
      file = request.files.get(&quot;file&quot;)
  
      filename = secure_filename(file.filename)
      saved_file = os.path.join(UPLOAD_FOLDER, filename)
      file.save(saved_file)
  
      resp = requests.post(url=URL, files={&quot;file&quot;: open(saved_file, &quot;rb&quot;)})
  
      return jsonify(resp.json())
  </code></pre>
  <p>However I want to eliminate saving the file on the server and directly post it to the third party url. Is there a way to send the incoming file object to a third party url without saving it or possibly save it in memory before posting it to the third party url?</p>