Move a file in the safest way possible:
>>> from django.core.files.move import file_move_safe >>> file_move_safe("/tmp/old_file", "/tmp/new_file")
Function | _samefile |
Undocumented |
Function | file_move_safe |
Move a file from one location to another in the safest way possible. |
Move a file from one location to another in the safest way possible.
First, try os.rename, which is simple but will break across filesystems. If that fails, stream manually from one file to another in pure Python.
If the destination file exists and allow_overwrite is False, raise FileExistsError.