package com.zd.face.utils;

import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * @Author: zhoupan
 * @Date: 2021/10/14/9:38
 * @Description:
 */
public class FileUtil {

    public static File multipartFileToFile(MultipartFile file) throws IOException {
        File toFile = null;


        String originalFilename = file.getOriginalFilename();
        String[] filename = originalFilename.split("\\.");
        toFile=File.createTempFile(filename[0], filename[1]);
        file.transferTo(toFile);
//        toFile.deleteOnExit();//在jvm 退出时删除
        return toFile;
    }



}
