mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2025-09-18 09:44:37 +08:00
新功能点:新增配置是否可以下载转换完成的pdf文件
This commit is contained in:
@@ -27,6 +27,7 @@ public class ConfigConstants {
|
||||
private static String BASE_URL;
|
||||
private static String FILE_DIR = OfficeUtils.getHomePath() + File.separator + "file" + File.separator;
|
||||
private static CopyOnWriteArraySet<String> TRUST_HOST_SET;
|
||||
private static String PDF_DOWNLOAD_DISABLE;
|
||||
|
||||
public static final String DEFAULT_CACHE_ENABLED = "true";
|
||||
public static final String DEFAULT_TXT_TYPE = "txt,html,htm,asp,jsp,xml,json,properties,md,gitignore,,java,py,c,cpp,sql,sh,bat,m,bas,prg,cmd";
|
||||
@@ -38,6 +39,7 @@ public class ConfigConstants {
|
||||
public static final String DEFAULT_BASE_URL = "default";
|
||||
public static final String DEFAULT_FILE_DIR_VALUE = "default";
|
||||
public static final String DEFAULT_TRUST_HOST = "default";
|
||||
public static final String DEFAULT_PDF_DOWNLOAD_DISABLE = "true";
|
||||
|
||||
public static Boolean isCacheEnabled() {
|
||||
return CACHE_ENABLED;
|
||||
@@ -141,4 +143,18 @@ public class ConfigConstants {
|
||||
private static void setTrustHostSet(CopyOnWriteArraySet<String> trustHostSet) {
|
||||
ConfigConstants.TRUST_HOST_SET = trustHostSet;
|
||||
}
|
||||
|
||||
|
||||
public static String getPdfDownloadDisable() {
|
||||
return PDF_DOWNLOAD_DISABLE;
|
||||
}
|
||||
|
||||
public static void setPdfDownloadDisableValue(String pdfDownloadDisable) {
|
||||
PDF_DOWNLOAD_DISABLE = pdfDownloadDisable;
|
||||
}
|
||||
|
||||
@Value("${pdf.download.disable:true}")
|
||||
public void setPdfDownloadDisable(String pdfDownloadDisable) {
|
||||
PDF_DOWNLOAD_DISABLE = pdfDownloadDisable;
|
||||
}
|
||||
}
|
||||
|
@@ -44,6 +44,7 @@ public class ConfigRefreshComponent {
|
||||
String configFilePath = OfficeUtils.getCustomizedConfigPath();
|
||||
String baseUrl;
|
||||
String trustHost;
|
||||
String pdfDownloadDisable;
|
||||
while (true) {
|
||||
FileReader fileReader = new FileReader(configFilePath);
|
||||
BufferedReader bufferedReader = new BufferedReader(fileReader);
|
||||
@@ -60,6 +61,7 @@ public class ConfigRefreshComponent {
|
||||
mediaArray = media.split(",");
|
||||
baseUrl = properties.getProperty("base.url", ConfigConstants.DEFAULT_BASE_URL);
|
||||
trustHost = properties.getProperty("trust.host", ConfigConstants.DEFAULT_TRUST_HOST);
|
||||
pdfDownloadDisable = properties.getProperty("pdf.download.disable", ConfigConstants.DEFAULT_PDF_DOWNLOAD_DISABLE);
|
||||
ConfigConstants.setCacheEnabled(cacheEnabled);
|
||||
ConfigConstants.setSimText(textArray);
|
||||
ConfigConstants.setMedia(mediaArray);
|
||||
@@ -69,6 +71,7 @@ public class ConfigRefreshComponent {
|
||||
ConfigConstants.setFtpControlEncoding(ftpControlEncoding);
|
||||
ConfigConstants.setBaseUrl(baseUrl);
|
||||
ConfigConstants.setTrustHost(trustHost);
|
||||
ConfigConstants.setPdfDownloadDisableValue(pdfDownloadDisable);
|
||||
setWatermarkConfig(properties);
|
||||
bufferedReader.close();
|
||||
fileReader.close();
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package cn.keking.web.controller;
|
||||
|
||||
import cn.keking.config.ConfigConstants;
|
||||
import cn.keking.hutool.URLUtil;
|
||||
import cn.keking.model.FileAttribute;
|
||||
import cn.keking.service.FilePreview;
|
||||
@@ -51,6 +52,7 @@ public class OnlinePreviewController {
|
||||
public String onlinePreview(String url, Model model, HttpServletRequest req) {
|
||||
FileAttribute fileAttribute = fileUtils.getFileAttribute(url);
|
||||
req.setAttribute("fileKey", req.getParameter("fileKey"));
|
||||
model.addAttribute("pdfDownloadDisable", ConfigConstants.getPdfDownloadDisable());
|
||||
model.addAttribute("officePreviewType", req.getParameter("officePreviewType"));
|
||||
FilePreview filePreview = previewFactory.get(fileAttribute);
|
||||
logger.info("预览文件url:{},previewType:{}", url, fileAttribute.getType());
|
||||
|
Reference in New Issue
Block a user