aidaV1.2
update the code until 25 May 2023
This commit is contained in:
@@ -188,6 +188,34 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
||||
* 将文件名解析成文件的上传路径
|
||||
*/
|
||||
public static File upload(MultipartFile file, String filePath) {
|
||||
Date date = new Date();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddhhmmssS");
|
||||
String suffix = getExtensionName(file.getOriginalFilename());
|
||||
String nowStr = format.format(date)+"-" ;
|
||||
try {
|
||||
String fileName = file.getOriginalFilename();
|
||||
String fileSuffix = fileName.substring(fileName.lastIndexOf("."));
|
||||
String path = filePath + fileSuffix;
|
||||
// getCanonicalFile 可解析正确各种路径
|
||||
File dest = new File(path).getCanonicalFile();
|
||||
// 检测是否存在目录
|
||||
if (!dest.getParentFile().exists()) {
|
||||
if (!dest.getParentFile().mkdirs()) {
|
||||
System.out.println("was not successful.");
|
||||
}
|
||||
}
|
||||
// 文件写入
|
||||
file.transferTo(dest);
|
||||
return dest;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 将文件名解析成文件的上传路径
|
||||
*/
|
||||
public static File upload2(MultipartFile file, String filePath) {
|
||||
Date date = new Date();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddhhmmssS");
|
||||
String suffix = getExtensionName(file.getOriginalFilename());
|
||||
@@ -211,6 +239,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*/
|
||||
|
||||
@@ -50,8 +50,8 @@ public final class LocalCacheUtils {
|
||||
private static LoadingCache<String, String> emailCache = CacheBuilder.newBuilder()
|
||||
//设置并发级别为5,并发级别是指可以同时写缓存的线程数
|
||||
.concurrencyLevel(10)
|
||||
//设置写缓存后3分钟过期
|
||||
.expireAfterWrite(60*3, TimeUnit.SECONDS)
|
||||
//设置写缓存后10分钟过期,防止跨洲发送慢失效问题
|
||||
.expireAfterWrite(60*30, TimeUnit.SECONDS)
|
||||
//刷新机制 每隔一定时间刷新缓存loader 只有调用get具体的操作才生效(懒加载) 不设置则不刷新
|
||||
// .refreshAfterWrite(60, TimeUnit.SECONDS)
|
||||
//设置缓存容器的初始容量为100
|
||||
|
||||
Reference in New Issue
Block a user