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?
The documentation does not have any details on how to handle such uploads either. How can I do this right?