(source_filename, relative_path=True)
Clone the file.

    :param string source_filename: Source filename.
    :param str relative_path:
    :return string: Filename of the cloned file.
Clone the file.
Clone the file .
def clone_file(source_filename, relative_path=True):
    """Clone the file.

    :param string source_filename: Source filename.
    :param str relative_path:
    :return string: Filename of the cloned file.
    """
    if source_filename.startswith(IMAGES_UPLOAD_DIR):
        source_filename = os.path.join(settings.MEDIA_ROOT, source_filename)

    destination_filename = ensure_unique_filename(source_filename)
    try:
        shutil.copyfile(source_filename, destination_filename)
        if relative_path:
            destination_filename = destination_filename.replace(
                settings.MEDIA_ROOT, ''
            )
            if destination_filename.startswith('/'):
                destination_filename = destination_filename[1:]
        return destination_filename
    except Exception as err:
        logger.debug(str(err))
def clone_file ( source_filename , relative_path = True ) : if source_filename . startswith ( IMAGES_UPLOAD_DIR ) : source_filename = os . path . join ( settings . MEDIA_ROOT , source_filename ) destination_filename = ensure_unique_filename ( source_filename ) try : shutil . copyfile ( source_filename , destination_filename ) if relative_path : destination_filename = destination_filename . replace ( settings . MEDIA_ROOT , '' ) if destination_filename . startswith ( '/' ) : destination_filename = destination_filename [ 1 : ] return destination_filename except Exception as err : logger . debug ( str ( err ) )