FileField need clean up temp file and and get file size without loading file
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Dashboard (Horizon) |
Invalid
|
High
|
Unassigned |
Bug Description
We are using forms.FileField to upload a client local file.
We noticed that if the file size is big, for example 7 gb, Horizon dumps a temp file in /tmp dir where horizon server runs. If the file loaded is different each time, the temp files are left in the /tmp. Over the long run, it could overflow the disk spaces.
We would like to have a way to clean up the tmp file once file loading is done.
The way that we use to get the file handle in the form's clean or handle method is :
f = self.request.
If we use this to get the file size in the clean method to validate, the whole file gets loaded either into memory or to temp dir, it would be nice to get the file size without loading the whole file.
summary: |
- FileField clean up temp file and and get file size without loading file + FileField need clean up temp file and and get file size without loading + file |
Changed in horizon: | |
importance: | Undecided → Medium |
importance: | Medium → High |
Changed in horizon: | |
assignee: | nobody → XiaojueGuan (xiaojuegaun) |
assignee: | XiaojueGuan (xiaojuegaun) → nobody |
Changed in horizon: | |
status: | Incomplete → Invalid |
Openstack forms.FileField inherited from Django, and when the upload file<2.5M, the file will write into memory, if >2.5M, it will write into the system temp folder. The attribute FILE_UPLOAD_ MAX_MEMORY_ SIZE is the file size threshold value whether write to memory or system temp folder. Seems we can set FILE_UPLOAD_ MAX_MEMORY_ SIZE to control.