提交 bcd49ed5 作者: ZhangJingKun

编辑最大文件现在

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