Uploading File from HTML Form to Contentul with Python

I have an HTML form that takes in user details and files and creates an entry in my Contentful space. The text content works fine but I don’t know how to go about having the user upload a file and then sending that file to my space and associating it with my entry. This is the code I have till now:

uploadmedia = request.files['fileupload']
client = Client('mykey')
new_upload = client.uploads('3qun4h5qq7tt').create(uploadmedia)
uid = "34573440034"
client.assets('3qun4h5qq7tt', 'master').create(uid,
   {
   'fields': {
      'file': {
         'en-US': {
         'fileName': uploadmedia.filename,
         'contentType': 'image/png',
         'uploadFrom': new_upload.to_link().to_json()
         }
      }
   }
   }
)

HTML field:

<label for="fileupload" >Project Files </label>
<input type="file"  name="fileupload"  id="fileupload"/>

And I do in fact see things happening in my Media tab, but they are perpetually ‘Loading’. What is up with that?

enter image description here

The documentation does not have any details on how to handle such uploads either. How can I do this right?

Hi @amanbhargava2001 ,

As I was answering in the other thread: How to upload a base64 or binary image? It is possible that the infinite loading is due to a missing filename (at least I got that error once). If you could add more information or any error log that you see during the execution, that could help identify the issue.