I am developing an application in django 2.1 in which I must upload an undetermined number of audios through a modal and then pass the information to the view from which the modal is launched. However, these audios should not be stored in the database until the main view form is filled out. Then I thought about these solutions:
First I thought about saving it as a session attribute but the contents of a FileField is not JSON serializable which did not work.
Second I thought about the LocalStorage property but if the files exceed the size I will have problems.
Third I thought about getting the file path and then create the audio but as I was reading is a bad practice and can only be obtained if the file is created on the disk, that is, if it is in TemporaryUploadedFile but my files should weigh less than one 1MB
For which I have the option that all files that are loaded with a size smaller than 2.5MB are stored in InMemoryUploadedFile but I do not know how to obtain them. Does anyone know how this is done? or how else can I save a list of temporary audios?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With