# -*- coding: utf-8 -*-

import os

import shortuuid
from django.core.files.storage import default_storage


def file_save(file_, prefix='img', ext='jpeg'):
    ext = os.path.splitext(file_.name)[-1] or ext
    path = '{}/{}{}'.format(prefix, shortuuid.uuid(), ext)
    if default_storage.exists(path):
        default_storage.delete(path)
    default_storage.save(path, file_)
    return path, ext
