module documentation
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 | file |
Move a file from one location to another in the safest way possible. |
Function | _samefile |
Undocumented |
def file_move_safe(old_file_name, new_file_name, chunk_size=1024*64, allow_overwrite=False):
(source)
¶
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``.