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 ​_samefile Undocumented
Function file​_move​_safe Move a file from one location to another in the safest way possible.
def _samefile(src, dst):

Undocumented

def file_move_safe(old_file_name, new_file_name, chunk_size=1024*64, allow_overwrite=False):

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.