mirror of https://github.com/elunez/eladmin
Merge remote-tracking branch 'origin/master'
# Conflicts: # eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.javapull/174/head
commit
5916cb2f50
|
@ -7,7 +7,6 @@ import cn.hutool.poi.excel.BigExcelWriter;
|
|||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import me.zhengjie.exception.BadRequestException;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.activation.MimetypesFileTypeMap;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -20,7 +19,6 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* File工具类,扩展 hutool 工具包
|
||||
*
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-27
|
||||
*/
|
||||
|
@ -46,7 +44,6 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||
|
||||
/**
|
||||
* MultipartFile转File
|
||||
*
|
||||
* @param multipartFile
|
||||
* @return
|
||||
*/
|
||||
|
@ -69,7 +66,6 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param files
|
||||
*/
|
||||
public static void deleteFile(File... files) {
|
||||
|
@ -82,7 +78,6 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||
|
||||
/**
|
||||
* 获取文件扩展名
|
||||
*
|
||||
* @param filename
|
||||
* @return
|
||||
*/
|
||||
|
@ -98,7 +93,6 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||
|
||||
/**
|
||||
* Java文件操作 获取不带扩展名的文件名
|
||||
*
|
||||
* @param filename
|
||||
* @return
|
||||
*/
|
||||
|
@ -114,7 +108,6 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||
|
||||
/**
|
||||
* 文件大小转换
|
||||
*
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
|
@ -137,14 +130,13 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||
|
||||
/**
|
||||
* inputStream 转 File
|
||||
*
|
||||
* @param ins
|
||||
* @param name
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static File inputStreamToFile(InputStream ins, String name) throws Exception{
|
||||
File file = new File(System.getProperty("java.io.tmpdir") + name);
|
||||
File file = new File(System.getProperty("java.io.tmpdir") + File.separator + name);
|
||||
if (file.exists()) {
|
||||
return file;
|
||||
}
|
||||
|
@ -174,12 +166,13 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||
String nowStr = "-" + format.format(date);
|
||||
try {
|
||||
String fileName = name + nowStr + "." + suffix;
|
||||
String path = filePath + File.separator + fileName;
|
||||
File dest = new File(path).getCanonicalFile();
|
||||
String path = filePath + fileName;
|
||||
File dest = new File(path);
|
||||
// 检测是否存在目录
|
||||
if (!dest.getParentFile().exists()) {
|
||||
dest.getParentFile().mkdirs();// 新建文件夹
|
||||
}
|
||||
String d = dest.getPath();
|
||||
file.transferTo(dest);// 文件写入
|
||||
return dest;
|
||||
} catch (Exception e) {
|
||||
|
@ -201,7 +194,6 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
* @throws Exception
|
||||
|
@ -244,7 +236,6 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||
String mimeType = new MimetypesFileTypeMap().getContentType("." + type);
|
||||
return mimeType.split("\\/")[0];
|
||||
}
|
||||
|
||||
public static void checkSize(long maxSize, long size) {
|
||||
if(size > (maxSize * 1024 * 1024)){
|
||||
throw new BadRequestException("文件超出规定大小");
|
||||
|
|
Loading…
Reference in New Issue