Commit c6ba23e7 by huluobin

update

parent 8eb189ac
......@@ -21,17 +21,25 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 费用模块文件上传、下载工具类
*/
@Slf4j
public class CostFileUtil {
private static final String REGEX_CHINESE = "[\u4e00-\u9fa5]";// 中文正则
public static String upload(MultipartFile file, String filePath) {
// 获取文件名
String fileName = file.getOriginalFilename();
// 去除中文
Pattern pat = Pattern.compile(REGEX_CHINESE);
Matcher mat = pat.matcher(fileName);
fileName = mat.replaceAll("");
// fileName处理
fileName = filePath + UUID.randomUUID() + "&" + fileName;
......@@ -43,8 +51,7 @@ public class CostFileUtil {
}
try {
file.transferTo(dest);
} catch (IOException e) {
// logger.error("affirmFile 发生错误",e);
} catch (IOException ignored) {
}
return fileName;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment