引入cpdetector解决文件编码识别问题

This commit is contained in:
chenkailing
2020-12-26 19:13:50 +08:00
committed by kl
parent f2d929e6fa
commit 342c391a9b
23 changed files with 240 additions and 400 deletions

View File

@ -4,7 +4,7 @@ import cn.keking.model.FileAttribute;
import cn.keking.model.ReturnResponse;
import cn.keking.service.FilePreview;
import cn.keking.utils.DownloadUtils;
import cn.keking.service.FilePreviewCommonService;
import cn.keking.service.FileHandlerService;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import org.springframework.util.CollectionUtils;
@ -18,13 +18,13 @@ import java.util.List;
@Service
public class PictureFilePreviewImpl implements FilePreview {
private final FilePreviewCommonService filePreviewCommonService;
private final FileHandlerService fileHandlerService;
private final DownloadUtils downloadUtils;
public PictureFilePreviewImpl(FilePreviewCommonService filePreviewCommonService,
public PictureFilePreviewImpl(FileHandlerService fileHandlerService,
DownloadUtils downloadUtils) {
this.filePreviewCommonService = filePreviewCommonService;
this.fileHandlerService = fileHandlerService;
this.downloadUtils = downloadUtils;
}
@ -33,7 +33,7 @@ public class PictureFilePreviewImpl implements FilePreview {
List<String> imgUrls = new ArrayList<>();
imgUrls.add(url);
String fileKey = fileAttribute.getFileKey();
List<String> zipImgUrls = filePreviewCommonService.getImgCache(fileKey);
List<String> zipImgUrls = fileHandlerService.getImgCache(fileKey);
if (!CollectionUtils.isEmpty(zipImgUrls)) {
imgUrls.addAll(zipImgUrls);
}
@ -45,7 +45,7 @@ public class PictureFilePreviewImpl implements FilePreview {
model.addAttribute("msg", response.getMsg());
return "fileNotSupported";
} else {
String file = filePreviewCommonService.getRelativePath(response.getContent());
String file = fileHandlerService.getRelativePath(response.getContent());
imgUrls.clear();
imgUrls.add(file);
model.addAttribute("imgurls", imgUrls);