package com.winsun.utils;

import com.winsun.auth.core.util.IOUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;

/**
 * @Author xuede
 * @Date 2020/3/6 10:29
 * @Version 1.0
 */
@Slf4j
public class FileUtil {

    //写到相应路径
    /*public  static boolean makefile(String path, MultipartFile file,String filename){

        File dir = new File(path);
        if (!dir.exists()) {
            dir.mkdirs();
        }
        File savePath = new File(dir, filename);
        OutputStream os = null;
        try {
            os = new FileOutputStream(savePath);
            os.write(file.getBytes());
            os.flush();
        } catch (Exception e) {
            log.error("上传文件失败：" + e.getMessage(), e);
            return false;
        } finally {
            if (os != null) {
                try{
                    os.close();
                }catch(Exception e) {}
            }
        }
        return true;
    }*/

    /*public  static boolean makefile1(String path, MultipartFile file,String filename){
        File dir = new File(path);
        if (!dir.exists()) {
            dir.mkdirs();
        }
        File savePath = new File(dir, filename);
        OutputStream os = null;
        try {
            os = new FileOutputStream(savePath);
            os.write(file.getBytes());
            os.flush();
        } catch (Exception e) {
            log.error("上传文件失败：" + e.getMessage(), e);
            return false;
        } finally {
            if (os != null) {
                IOUtils.closeQuite(os);
            }
        }
        return true;
    }*/
}
