Browse Source

新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录

新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录

Signed-off-by: 高雄 <admin@cxcp.com>
pull/84/head
高雄 2 years ago committed by Gitee
parent
commit
4cd6a4e4b9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
  1. 21
      server/src/main/java/cn/keking/web/controller/FileController.java

21
server/src/main/java/cn/keking/web/controller/FileController.java

@ -3,8 +3,8 @@ package cn.keking.web.controller;
import cn.keking.config.ConfigConstants;
import cn.keking.model.ReturnResponse;
import cn.keking.utils.KkFileUtils;
import cn.keking.utils.RarUtils;
import cn.keking.utils.WebUtils;
import cn.keking.service.CompressFileReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.ObjectUtils;
@ -21,12 +21,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
/**
* @author yudian-it
@ -145,7 +140,7 @@ public class FileController {
*/
private ReturnResponse<Object> deleteFileCheck(String fileName) {
if (ObjectUtils.isEmpty(fileName)) {
return ReturnResponse.failure("文件名为空,删除失败!");
return ReturnResponse.failure("文件名为空!");
}
try {
fileName = WebUtils.decodeUrl(fileName);
@ -165,20 +160,18 @@ public class FileController {
@GetMapping("/directory")
public Object directory(String urls) {
if (ObjectUtils.isEmpty(urls)) {
return ReturnResponse.failure("地址不合法!");
ReturnResponse<Object> checkResult = this.deleteFileCheck(urls);
if (checkResult.isFailure()) {
return checkResult;
}
String fileUrl;
try {
fileUrl = WebUtils.decodeUrl(urls);
if (fileUrl.toLowerCase().startsWith("file:") || fileUrl.toLowerCase().startsWith("file%3")) {
return ReturnResponse.failure("地址不合法!");
}
} catch (Exception ex) {
String errorMsg = String.format(BASE64_DECODE_ERROR_MSG, "url");
return errorMsg;
}
return CompressFileReader.getTree(fileUrl);
return RarUtils.getTree(fileUrl);
}
private boolean existsFile(String fileName) {

Loading…
Cancel
Save