Commit b048875d authored by luzhuang's avatar luzhuang

txt限制10M

parent 7b29d7fe
...@@ -111,6 +111,9 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -111,6 +111,9 @@ public class BChapterServiceImpl implements BChapterService {
@Value("${upload.pdfMaxSize:150}") @Value("${upload.pdfMaxSize:150}")
private Long pdfMaxSize; private Long pdfMaxSize;
@Value("${upload.txtMaxSize:10}")
private Long txtMaxSize;
@Value("${upload.replaceHttp:false}") @Value("${upload.replaceHttp:false}")
private String replaceHttp; private String replaceHttp;
...@@ -744,7 +747,7 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -744,7 +747,7 @@ public class BChapterServiceImpl implements BChapterService {
if ("7".equals(bFile.getType()) || "8".equals(bFile.getType()) || "9".equals(bFile.getType()) || "10".equals(bFile.getType())){ if ("7".equals(bFile.getType()) || "8".equals(bFile.getType()) || "9".equals(bFile.getType()) || "10".equals(bFile.getType())){
FileReadableUtil.imgReadable(path); FileReadableUtil.imgReadable(path);
}else { }else {
FileReadableUtil.fileReadable(path, fileMaxSize,pdfMaxSize, fileMaxPages); FileReadableUtil.fileReadable(path, fileMaxSize,pdfMaxSize,txtMaxSize, fileMaxPages);
} }
return flag; return flag;
} }
...@@ -807,7 +810,7 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -807,7 +810,7 @@ public class BChapterServiceImpl implements BChapterService {
} else { } else {
String downLoadName = downLoadFile(bFile, file, filePath); String downLoadName = downLoadFile(bFile, file, filePath);
LogUtil.fileChangeLog("------------------判断pdf是否可读----------------------------" + fileOld); LogUtil.fileChangeLog("------------------判断pdf是否可读----------------------------" + fileOld);
FileReadableUtil.fileReadable(filePath + File.separator + downLoadName, fileMaxSize,pdfMaxSize, fileMaxPages); FileReadableUtil.fileReadable(filePath + File.separator + downLoadName, fileMaxSize,pdfMaxSize,txtMaxSize, fileMaxPages);
LogUtil.fileChangeLog("------------------pdf文件可读--返回下载后路径-----------------------------" + downLoadName); LogUtil.fileChangeLog("------------------pdf文件可读--返回下载后路径-----------------------------" + downLoadName);
return returnBasePath + File.separator + downLoadName; return returnBasePath + File.separator + downLoadName;
} }
...@@ -841,7 +844,7 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -841,7 +844,7 @@ public class BChapterServiceImpl implements BChapterService {
//判断文件是否可读 //判断文件是否可读
LogUtil.fileChangeLog("------------------判断文件是否可读-----------------------------" + filePath + File.separator + name); LogUtil.fileChangeLog("------------------判断文件是否可读-----------------------------" + filePath + File.separator + name);
FileReadableUtil.fileReadable(filePath + File.separator + downLoadFileName, fileMaxSize,pdfMaxSize, fileMaxPages); FileReadableUtil.fileReadable(filePath + File.separator + downLoadFileName, fileMaxSize,pdfMaxSize,txtMaxSize, fileMaxPages);
LogUtil.fileChangeLog("------------------------非pdf文件可读-----------------------"+ downLoadFileName); LogUtil.fileChangeLog("------------------------非pdf文件可读-----------------------"+ downLoadFileName);
LogUtil.fileChangeLog("-----------------------------------------------downLoadFileUrl:" + filePath + File.separator + downLoadFileName); LogUtil.fileChangeLog("-----------------------------------------------downLoadFileUrl:" + filePath + File.separator + downLoadFileName);
LogUtil.fileChangeLog("-----------------------------------------------filePath:" + filePath + File.separator + newName); LogUtil.fileChangeLog("-----------------------------------------------filePath:" + filePath + File.separator + newName);
......
...@@ -190,7 +190,7 @@ public class FileReadableUtil { ...@@ -190,7 +190,7 @@ public class FileReadableUtil {
} }
public static void fileReadable(String path,Long fileMaxSize,Long pdfMaxSize,Integer fileMaxPages) { public static void fileReadable(String path,Long fileMaxSize,Long pdfMaxSize,Long txtMaxSize,Integer fileMaxPages) {
LogUtil.fileChangeLog("-----------FileReadableUtil-路径------------"+path); LogUtil.fileChangeLog("-----------FileReadableUtil-路径------------"+path);
File file = new File(path); File file = new File(path);
Long size = file.length(); Long size = file.length();
...@@ -198,6 +198,10 @@ public class FileReadableUtil { ...@@ -198,6 +198,10 @@ public class FileReadableUtil {
if (size > (long)(1024 * 1024 * pdfMaxSize)){ if (size > (long)(1024 * 1024 * pdfMaxSize)){
throw new ServiceException(400,"该文件超过最大"+pdfMaxSize+"M限制"); throw new ServiceException(400,"该文件超过最大"+pdfMaxSize+"M限制");
} }
}else if("txt".equals(path.substring(path.lastIndexOf(".") + 1))){
if (size > (long)(1024 * 1024 * txtMaxSize)){
throw new ServiceException(400,"该文件超过最大"+txtMaxSize+"M限制");
}
}else{ }else{
if (size > (long)(1024 * 1024 * fileMaxSize)){ if (size > (long)(1024 * 1024 * fileMaxSize)){
throw new ServiceException(400,"该文件超过最大"+fileMaxSize+"M限制"); throw new ServiceException(400,"该文件超过最大"+fileMaxSize+"M限制");
......
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