package com.fufan.mtsaas.tools;

import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 文件处理工具
 *
 * @version 1.0
 * @auther Liby
 * @create 2018/4/28
 **/
@Slf4j
public class FileUtil {

    public static void uploadFile(byte[] file, String filePath, String fileName) {
        File targetFile = new File(filePath);
        if(!targetFile.exists()){
            targetFile.mkdirs();
        }
        FileOutputStream out = null;
        try {
            out = new FileOutputStream(filePath+fileName);
            out.write(file);
            out.flush();
            out.close();
        } catch (FileNotFoundException e) {
            log.error("文件存储失败：", e);
        } catch (IOException e) {
            log.error("文件存储失败：", e);
        }
    }
}
