Question

How does the FileField.save() work behind the scenes for files over 2.5M? I read on another post that the FileField.save() will do auto chunking of the file to be saved. But would you need chunking if you are saving the file onto the same machine as the tmp directory where files over 2.5M are saved? In large file size upload situations where the tmp directory is on the same machine where I want to save the file, does save() just mv the file to the target directory from the tmp directory and bypass chunking?

Was it helpful?

Solution

That's not about handling uploaded file when saving it to model, in that case move in used. It's about storing that file during upload process - small files are being put into memory, larger ones are split into chunks and writte in temporary file.

About saving files:

https://github.com/django/django/blob/master/django/db/models/fields/files.py

https://github.com/django/django/blob/master/django/core/files/storage.py

About uploading:

https://github.com/django/django/blob/master/django/core/files/uploadedfile.py

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top