How to get the files uploaded in InMemoryUploadedFile django
InMemoryUploadedFile is a wrapper around a file object. You can access the file object using the file attribute.
file_in_memory # <InMemoryUploadedFile: xxx (xxx/xxx)>file_object = file_in_memory.file
ClientSide :
var file = document.getElementById('file'); const formData = new FormData(); formData.append('file', file[0]); fetch('api/upload_file/',{ method:'POST', body:formData }).then(res => console.log(res); .catch(error => console.log(error);
On Server Side:
InMemoryUploadedFile can be accessed as:
file = request.FILES.get('file')