When uploading a file for a field such as this one:
file = FileField(upload_to='/path/')
Django uses either an InMemoryUploadedFile
or a TemporaryUploadedFile
. The latter is stored on the disk and its file name can be accessed with the temporary_file_path
property. The storage choice depends on the file size.
How can I override this behaviour and always upload as a TemporaryUploadedFile
for this model field?
The reason I am asking this is because I need to write a validator that uses an external library that can only take file paths as input, no data streams.