When does Django delete downloaded files from a temporary directory?

According to docs :

However, if the downloaded file is too large, Django will write the downloaded file to a temporary file stored on your systems, a temporary directory. On a Unix-like platform, this means that you can expect Django to generate a file with the name /tmp/tmpzfp6I6.upload. If the load is large enough, you can see how this file grows in size, as Django streams data to disk.

So, I loaded the same large file several times into the view and got the following:

vic@vic /tmp $ ls -l tmp*.upload
-rw------- 1 vic vic2 3436110    14 18:31 tmpKdZrQl.upload
-rw------- 1 vic vic2 3436110    14 18:31 tmpqLyBsy.upload

When are these files removed from the temp directory?

I want to avoid bloating the temp directory.

+4
1

, Django tempfile python. django django/core/files/temp.py.

django temp tempfile.NamedTemporaryFile. . ( , django) , , .

filehandle; , , .

+8

Source: https://habr.com/ru/post/1540534/


All Articles