新增备案信息,禁止上传类型,删除支持密码功能

新增备案信息,禁止上传类型,删除支持密码功能

Signed-off-by: 高雄 <admin@cxcp.com>
pull/85/head
高雄 2 years ago committed by Gitee
parent 181897ec5a
commit 75a46a14a8
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

@ -60,11 +60,15 @@ public class FileController {
} }
@GetMapping("/deleteFile") @GetMapping("/deleteFile")
public ReturnResponse<Object> deleteFile(String fileName) { public ReturnResponse<Object> deleteFile(String fileName,String password) {
ReturnResponse<Object> checkResult = this.deleteFileCheck(fileName); ReturnResponse<Object> checkResult = this.deleteFileCheck(fileName);
if (checkResult.isFailure()) { if (checkResult.isFailure()) {
return checkResult; return checkResult;
} }
if(!ConfigConstants.getpassword().equalsIgnoreCase(password)){
logger.error("删除文件【{}】失败,密码错误!",fileName);
return ReturnResponse.failure("删除文件失败,密码错误!");
}
fileName = checkResult.getContent().toString(); fileName = checkResult.getContent().toString();
File file = new File(fileDir + demoPath + fileName); File file = new File(fileDir + demoPath + fileName);
logger.info("删除文件:{}", file.getAbsolutePath()); logger.info("删除文件:{}", file.getAbsolutePath());
@ -103,8 +107,10 @@ public class FileController {
return ReturnResponse.failure("文件传接口已禁用"); return ReturnResponse.failure("文件传接口已禁用");
} }
String fileName = WebUtils.getFileNameFromMultipartFile(file); String fileName = WebUtils.getFileNameFromMultipartFile(file);
if(fileName.lastIndexOf(".")==-1){
if (!isAllowedUpload(fileName)) { return ReturnResponse.failure("不允许上传的类型");
}
if (!KkFileUtils.isAllowedUpload(fileName)) {
return ReturnResponse.failure("不允许上传的文件类型: " + fileName); return ReturnResponse.failure("不允许上传的文件类型: " + fileName);
} }
if (KkFileUtils.isIllegalFileName(fileName)) { if (KkFileUtils.isIllegalFileName(fileName)) {
@ -117,20 +123,6 @@ public class FileController {
return ReturnResponse.success(fileName); return ReturnResponse.success(fileName);
} }
/**
*
*
* @param file
* @return
*/
private boolean isAllowedUpload(String file) {
String fileType = KkFileUtils.suffixFromFileName(file);
for (String type : not_allowed) {
if (type.equals(fileType))
return false;
}
return !ObjectUtils.isEmpty(fileType);
}
/** /**
* *

Loading…
Cancel
Save