import { randomUUID } from "crypto";
import { diskStorage } from "multer";


const MIME_TYPES = {
	'image/jpg': 'jpg',
	'image/jpeg': 'jpg',
	'image/png': 'png'
};


export const storageForAvatar = {
	storage: diskStorage({
		destination: './uploads/avatars',
		filename: (req, file, cb) => {
				const filename : string = file.originalname.split(' ').join('_') +  randomUUID();
				console.log("RES : " )
				const extension : string = MIME_TYPES[file.mimetype];
				cb(null, `${filename}${extension}`);
			}
		})
}
