title: Python: Getting local file path from request.files
body: <p>I need help uploading a file directly from an HTML form to an API. I've seen this being done for remote URLs, but I don't know how to do this for local files? I tried writing this, but its not working:</p>
  <pre class="lang-py prettyprint-override"><code>uploadmedia = request.files['fileupload']
  client = Client('thisismykey')
  with open(uploadmedia, 'rb') as file:
    new_upload = client.uploads('&lt;space-id&gt;').create(file)
  </code></pre>
  <p>The line <code>client.uploads</code> is what is specified in the API docs <a href="https://github.com/contentful/contentful-management.py#uploads" rel="nofollow noreferrer">here</a>. I just need to be able to get the file path.</p>
  <p>The comments suggest the following:</p>
  <pre><code># you can use either a file-like object or a path.
  # If you use a path, the SDK will open it, create the upload and
  # close the file afterwards.
  </code></pre>
  <p>I am assuming that <code>request.files['fileupload']</code> is a file like object, so I just passed that along.</p>
  <p>The above code gives me the following error:</p>
  <pre><code>File &quot;D:\Gatsby\submission\flask-tailwindcss-starter\app\__init__.py&quot;, line 28, in index
  with open(uploadmedia, 'rb') as file:
  TypeError: expected str, bytes or os.PathLike object, not FileStorage
  </code></pre>
  <p>I know that in this example, <code>uploadmedia.filename</code> would get me the file's name, but what is the attribute for the path? How do I do that?</p>