提交 bcd49ed5 作者: ZhangJingKun

编辑最大文件现在

上级 b32d537c
...@@ -45,8 +45,8 @@ public class DocumentServiceImpl implements DocumentService { ...@@ -45,8 +45,8 @@ public class DocumentServiceImpl implements DocumentService {
/** /**
* 大小限制,默认10M * 大小限制,默认10M
*/ */
@Value("${document.file-size.limit:10485760}") @Value("${filesize-max}")
private Long docFileSizeLimit; private String filesizeMax;
@Value("${files.docservice.url.site}") @Value("${files.docservice.url.site}")
private String documentServerHost; private String documentServerHost;
@Value("${files.docservice.url.api}") @Value("${files.docservice.url.api}")
...@@ -293,8 +293,8 @@ public class DocumentServiceImpl implements DocumentService { ...@@ -293,8 +293,8 @@ public class DocumentServiceImpl implements DocumentService {
log.error("$$$ 目标文档[{}]不可读,无法打开!", docFile.getAbsolutePath()); log.error("$$$ 目标文档[{}]不可读,无法打开!", docFile.getAbsolutePath());
throw new DocumentException(ErrorCodeEnum.DOC_FILE_UNREADABLE); throw new DocumentException(ErrorCodeEnum.DOC_FILE_UNREADABLE);
} }
if (docFile.length() > docFileSizeLimit) { if (docFile.length() > Long.parseLong(filesizeMax)) {
log.error("$$$ 目标文档大小超过限制({}B > {}B),无法打开!", docFile.length(), docFileSizeLimit); log.error("$$$ 目标文档大小超过限制({}B > {}B),无法打开!", docFile.length(), Long.parseLong(filesizeMax));
throw new DocumentException(ErrorCodeEnum.DOC_FILE_OVERSIZE); throw new DocumentException(ErrorCodeEnum.DOC_FILE_OVERSIZE);
} }
String ext = StringUtils.lowerCase(FilenameUtils.getExtension(docFile.getName())); String ext = StringUtils.lowerCase(FilenameUtils.getExtension(docFile.getName()));
......
...@@ -80,6 +80,7 @@ public class LocalFileServiceImpl implements ILocalFileService { ...@@ -80,6 +80,7 @@ public class LocalFileServiceImpl implements ILocalFileService {
String fileExtension = fileUtility.getFileExtension(fileName); // 获取文件扩展名 String fileExtension = fileUtility.getFileExtension(fileName); // 获取文件扩展名
String fileType = fileUtility.getFileType(fileName); //获取文件类型 String fileType = fileUtility.getFileType(fileName); //获取文件类型
long fileSize = file.getSize(); // get file size long fileSize = file.getSize(); // get file size
log.info("文件上传:"+ fileName);
// check if the file size exceeds the maximum file size or is less than 0 // check if the file size exceeds the maximum file size or is less than 0
if (fileUtility.getMaxFileSize() < fileSize || fileSize <= 0) { if (fileUtility.getMaxFileSize() < fileSize || fileSize <= 0) {
...@@ -107,6 +108,7 @@ public class LocalFileServiceImpl implements ILocalFileService { ...@@ -107,6 +108,7 @@ public class LocalFileServiceImpl implements ILocalFileService {
knowFile.setFileType(fileType); knowFile.setFileType(fileType);
knowFile.setFileSize(fileSize); knowFile.setFileSize(fileSize);
Result result = Result.OK(knowFile); Result result = Result.OK(knowFile);
log.info("文件上传成功:" + fileName + "---" + filePath);
return result; // create user metadata and return it return result; // create user metadata and return it
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论