9👍
✅
The InMemoryUploadedFile
does not provide temporary_file_path
. The content lives ‘in memory’ – as the class name implies.
By default Django uses InMemoryUploadedFile
for files up to 2.5MB size, larger files use TemporaryFileUploadHandler
. where the later provides the temporary_file_path
method in question. Django Documentation
So an easy way would be to change your settings for FILE_UPLOAD_HANDLERS to always use TemporaryFileUploadHandler
:
FILE_UPLOAD_HANDLERS = [
'django.core.files.uploadhandler.TemporaryFileUploadHandler',
]
Just keep in mind that this is not the most efficient way when you have a site with a lot of concurrent small upload requests.
Source:stackexchange.com