commit
26d8c7ab62
|
@ -34,9 +34,10 @@ public class CompressFileReader {
|
||||||
public String unRar(String filePath, String filePassword, String fileName, String fileKey) throws Exception {
|
public String unRar(String filePath, String filePassword, String fileName, String fileKey) throws Exception {
|
||||||
List<String> imgUrls = new ArrayList<>();
|
List<String> imgUrls = new ArrayList<>();
|
||||||
String baseUrl = BaseUrlFilter.getBaseUrl();
|
String baseUrl = BaseUrlFilter.getBaseUrl();
|
||||||
|
String packagePath = "_"; //防止文件名重复 压缩包统一生成文件添加_符号
|
||||||
String folderName = filePath.replace(fileDir, ""); //修复压缩包 多重目录获取路径错误
|
String folderName = filePath.replace(fileDir, ""); //修复压缩包 多重目录获取路径错误
|
||||||
if (!ObjectUtils.isEmpty(fileKey)) { //压缩包文件 直接赋予路径 不予下载
|
if (!ObjectUtils.isEmpty(fileKey)) { //压缩包文件 直接赋予路径 不予下载
|
||||||
folderName = "_decompression"+folderName;
|
folderName = "_decompression"+folderName; //重新修改多重压缩包 生成文件路径
|
||||||
}
|
}
|
||||||
RandomAccessFile randomAccessFile = null;
|
RandomAccessFile randomAccessFile = null;
|
||||||
IInArchive inArchive = null;
|
IInArchive inArchive = null;
|
||||||
|
@ -57,11 +58,11 @@ public class CompressFileReader {
|
||||||
}
|
}
|
||||||
str[0] = str[0].replace("\\", File.separator); //Linux 下路径错误
|
str[0] = str[0].replace("\\", File.separator); //Linux 下路径错误
|
||||||
String str1 = str[0].substring(0, str[0].lastIndexOf(File.separator)+ 1);
|
String str1 = str[0].substring(0, str[0].lastIndexOf(File.separator)+ 1);
|
||||||
File file = new File(fileDir, finalFolderName + "_" + File.separator + str1);
|
File file = new File(fileDir, finalFolderName + packagePath + File.separator + str1);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file.mkdirs();
|
file.mkdirs();
|
||||||
}
|
}
|
||||||
OutputStream out = new FileOutputStream( fileDir+ finalFolderName + "_" + File.separator + str[0], true);
|
OutputStream out = new FileOutputStream( fileDir+ finalFolderName + packagePath + File.separator + str[0], true);
|
||||||
IOUtils.write(data, out);
|
IOUtils.write(data, out);
|
||||||
out.close();
|
out.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -73,15 +74,15 @@ public class CompressFileReader {
|
||||||
if (result == ExtractOperationResult.OK) {
|
if (result == ExtractOperationResult.OK) {
|
||||||
FileType type = FileType.typeFromUrl(str[0]);
|
FileType type = FileType.typeFromUrl(str[0]);
|
||||||
if (type.equals(FileType.PICTURE)) {
|
if (type.equals(FileType.PICTURE)) {
|
||||||
imgUrls.add(baseUrl +folderName + "_/" + str[0].replace("\\", "/"));
|
imgUrls.add(baseUrl +folderName + packagePath +"/" + str[0].replace("\\", "/"));
|
||||||
}
|
}
|
||||||
fileHandlerService.putImgCache(fileName, imgUrls);
|
fileHandlerService.putImgCache(fileName+ packagePath, imgUrls);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return folderName + "_";
|
return folderName + packagePath;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -454,18 +454,21 @@ public class FileHandlerService implements InitializingBean {
|
||||||
}
|
}
|
||||||
if (!ObjectUtils.isEmpty(fileKey)) { //判断是否使用特定压缩包符号
|
if (!ObjectUtils.isEmpty(fileKey)) { //判断是否使用特定压缩包符号
|
||||||
try {
|
try {
|
||||||
|
// http://127.0.0.1:8012/各类型文件1 - 副本.zip_/各类型文件/正常预览/PPT转的PDF.pdf?kkCompressfileKey=各类型文件1 - 副本.zip_
|
||||||
|
// http://127.0.0.1:8012/preview/各类型文件1 - 副本.zip_/各类型文件/正常预览/PPT转的PDF.pdf?kkCompressfileKey=各类型文件1 - 副本.zip_ 获取路径就会错误 需要下面的方法
|
||||||
URL urll = new URL(url);
|
URL urll = new URL(url);
|
||||||
fileName = urll.getPath(); //压缩包类型文件 获取解压后的绝对地址 不在执行重复下载方法
|
String _Path = urll.getPath(); //获取url路径
|
||||||
|
String urlStrr = getSubString(_Path, fileKey); //反代情况下添加前缀,只获取有压缩包字符的路径
|
||||||
|
fileName = fileKey + urlStrr.trim(); //拼接完整路径
|
||||||
attribute.setSkipDownLoad(true);
|
attribute.setSkipDownLoad(true);
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
url = WebUtils.encodeUrlFileName(url);
|
url = WebUtils.encodeUrlFileName(url);
|
||||||
if(UrlEncoderUtils.hasUrlEncoded(fileName) && UrlEncoderUtils.hasUrlEncoded(suffix)){ //判断文件名是否转义
|
if(UrlEncoderUtils.hasUrlEncoded(fileName)){ //判断文件名是否转义
|
||||||
try {
|
try {
|
||||||
fileName = URLDecoder.decode(fileName, "UTF-8").replaceAll("\\+", "%20").replaceAll(" ", "%20");
|
fileName = URLDecoder.decode(fileName, uriEncoding).replaceAll("\\+", "%20");
|
||||||
suffix = URLDecoder.decode(suffix, "UTF-8");
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
|
|
||||||
function chooseNode(event, treeId, treeNode) {
|
function chooseNode(event, treeId, treeNode) {
|
||||||
if (!treeNode.isParent) {
|
if (!treeNode.isParent) {
|
||||||
var path = '${baseUrl}' + treeNode.id + "?kkCompressfileKey=" + '${fileName}';
|
var path = '${baseUrl}' + treeNode.id + "?kkCompressfileKey=" + '${fileTree}';
|
||||||
location.href = "${baseUrl}onlinePreview?url=" + encodeURIComponent(Base64.encode(path));
|
location.href = "${baseUrl}onlinePreview?url=" + encodeURIComponent(Base64.encode(path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue