Commit fcdefa45 authored by 陈精华's avatar 陈精华

新功能点:首页文件上传功能可通过配置实时开启或禁用

parent dc50a460
...@@ -67,6 +67,8 @@ office.preview.switch.disabled = ${KK_OFFICE_PREVIEW_SWITCH_DISABLED:false} ...@@ -67,6 +67,8 @@ office.preview.switch.disabled = ${KK_OFFICE_PREVIEW_SWITCH_DISABLED:false}
#是否禁止下载转换生成的pdf文件 #是否禁止下载转换生成的pdf文件
pdf.download.disable = ${KK_PDF_DOWNLOAD_DISABLE:true} pdf.download.disable = ${KK_PDF_DOWNLOAD_DISABLE:true}
#是否禁用首页文件上传
file.upload.disable = ${KK_FILE_UPLOAD_ENABLED:false}
#预览源为FTP时 FTP用户名,可在ftp url后面加参数ftp.username=ftpuser指定,不指定默认用配置的 #预览源为FTP时 FTP用户名,可在ftp url后面加参数ftp.username=ftpuser指定,不指定默认用配置的
ftp.username = ${KK_FTP_USERNAME:ftpuser} ftp.username = ${KK_FTP_USERNAME:ftpuser}
......
...@@ -35,6 +35,7 @@ public class ConfigConstants { ...@@ -35,6 +35,7 @@ public class ConfigConstants {
private static String fileDir = ConfigUtils.getHomePath() + File.separator + "file" + File.separator; private static String fileDir = ConfigUtils.getHomePath() + File.separator + "file" + File.separator;
private static CopyOnWriteArraySet<String> trustHostSet; private static CopyOnWriteArraySet<String> trustHostSet;
private static String pdfDownloadDisable; private static String pdfDownloadDisable;
private static Boolean fileUploadDisable;
public static final String DEFAULT_CACHE_ENABLED = "true"; 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,log,java,py,c,cpp,sql,sh,bat,m,bas,prg,cmd"; public static final String DEFAULT_TXT_TYPE = "txt,html,htm,asp,jsp,xml,json,properties,md,gitignore,log,java,py,c,cpp,sql,sh,bat,m,bas,prg,cmd";
...@@ -48,6 +49,7 @@ public class ConfigConstants { ...@@ -48,6 +49,7 @@ public class ConfigConstants {
public static final String DEFAULT_FILE_DIR_VALUE = "default"; public static final String DEFAULT_FILE_DIR_VALUE = "default";
public static final String DEFAULT_TRUST_HOST = "default"; public static final String DEFAULT_TRUST_HOST = "default";
public static final String DEFAULT_PDF_DOWNLOAD_DISABLE = "true"; public static final String DEFAULT_PDF_DOWNLOAD_DISABLE = "true";
public static final String DEFAULT_FILE_UPLOAD_DISABLE = "false";
public static Boolean isCacheEnabled() { public static Boolean isCacheEnabled() {
...@@ -250,4 +252,16 @@ public class ConfigConstants { ...@@ -250,4 +252,16 @@ public class ConfigConstants {
ConfigConstants.officePreviewSwitchDisabled = officePreviewSwitchDisabled; ConfigConstants.officePreviewSwitchDisabled = officePreviewSwitchDisabled;
} }
public static Boolean getFileUploadDisable() {
return fileUploadDisable;
}
@Value("${file.upload.disable:false}")
public static void setFileUploadDisable(Boolean fileUploadDisable) {
setFileUploadDisableValue(fileUploadDisable);
}
public static void setFileUploadDisableValue(Boolean fileUploadDisable) {
ConfigConstants.fileUploadDisable = fileUploadDisable;
}
} }
...@@ -48,6 +48,7 @@ public class ConfigRefreshComponent { ...@@ -48,6 +48,7 @@ public class ConfigRefreshComponent {
String baseUrl; String baseUrl;
String trustHost; String trustHost;
String pdfDownloadDisable; String pdfDownloadDisable;
boolean fileUploadDisable;
while (true) { while (true) {
FileReader fileReader = new FileReader(configFilePath); FileReader fileReader = new FileReader(configFilePath);
BufferedReader bufferedReader = new BufferedReader(fileReader); BufferedReader bufferedReader = new BufferedReader(fileReader);
...@@ -66,6 +67,7 @@ public class ConfigRefreshComponent { ...@@ -66,6 +67,7 @@ public class ConfigRefreshComponent {
baseUrl = properties.getProperty("base.url", ConfigConstants.DEFAULT_BASE_URL); baseUrl = properties.getProperty("base.url", ConfigConstants.DEFAULT_BASE_URL);
trustHost = properties.getProperty("trust.host", ConfigConstants.DEFAULT_TRUST_HOST); trustHost = properties.getProperty("trust.host", ConfigConstants.DEFAULT_TRUST_HOST);
pdfDownloadDisable = properties.getProperty("pdf.download.disable", ConfigConstants.DEFAULT_PDF_DOWNLOAD_DISABLE); pdfDownloadDisable = properties.getProperty("pdf.download.disable", ConfigConstants.DEFAULT_PDF_DOWNLOAD_DISABLE);
fileUploadDisable = Boolean.parseBoolean(properties.getProperty("file.upload.disable", ConfigConstants.DEFAULT_FILE_UPLOAD_DISABLE));
ConfigConstants.setCacheEnabledValueValue(cacheEnabled); ConfigConstants.setCacheEnabledValueValue(cacheEnabled);
ConfigConstants.setSimTextValue(textArray); ConfigConstants.setSimTextValue(textArray);
ConfigConstants.setMediaValue(mediaArray); ConfigConstants.setMediaValue(mediaArray);
...@@ -77,6 +79,7 @@ public class ConfigRefreshComponent { ...@@ -77,6 +79,7 @@ public class ConfigRefreshComponent {
ConfigConstants.setTrustHostValue(trustHost); ConfigConstants.setTrustHostValue(trustHost);
ConfigConstants.setOfficePreviewSwitchDisabledValue(officePreviewSwitchDisabled); ConfigConstants.setOfficePreviewSwitchDisabledValue(officePreviewSwitchDisabled);
ConfigConstants.setPdfDownloadDisableValue(pdfDownloadDisable); ConfigConstants.setPdfDownloadDisableValue(pdfDownloadDisable);
ConfigConstants.setFileUploadDisableValue(fileUploadDisable);
setWatermarkConfig(properties); setWatermarkConfig(properties);
bufferedReader.close(); bufferedReader.close();
fileReader.close(); fileReader.close();
......
...@@ -35,6 +35,9 @@ public class FileController { ...@@ -35,6 +35,9 @@ public class FileController {
@RequestMapping(value = "fileUpload", method = RequestMethod.POST) @RequestMapping(value = "fileUpload", method = RequestMethod.POST)
public String fileUpload(@RequestParam("file") MultipartFile file) throws JsonProcessingException { public String fileUpload(@RequestParam("file") MultipartFile file) throws JsonProcessingException {
if (ConfigConstants.getFileUploadDisable()) {
return new ObjectMapper().writeValueAsString(ReturnResponse.failure("文件传接口已禁用"));
}
// 获取文件名 // 获取文件名
String fileName = file.getOriginalFilename(); String fileName = file.getOriginalFilename();
//判断是否为IE浏览器的文件名,IE浏览器下文件名会带有盘符信息 //判断是否为IE浏览器的文件名,IE浏览器下文件名会带有盘符信息
......
...@@ -34,7 +34,7 @@ public class AttributeSetFilter implements Filter { ...@@ -34,7 +34,7 @@ public class AttributeSetFilter implements Filter {
request.setAttribute("pdfDownloadDisable", ConfigConstants.getPdfDownloadDisable()); request.setAttribute("pdfDownloadDisable", ConfigConstants.getPdfDownloadDisable());
request.setAttribute("fileKey", httpRequest.getParameter("fileKey")); request.setAttribute("fileKey", httpRequest.getParameter("fileKey"));
request.setAttribute("switchDisabled", ConfigConstants.getOfficePreviewSwitchDisabled()); request.setAttribute("switchDisabled", ConfigConstants.getOfficePreviewSwitchDisabled());
request.setAttribute("fileUploadDisable", ConfigConstants.getFileUploadDisable());
} }
/** /**
......
...@@ -53,6 +53,7 @@ public class FilterConfiguration { ...@@ -53,6 +53,7 @@ public class FilterConfiguration {
@Bean @Bean
public FilterRegistrationBean getWatermarkConfigFilter() { public FilterRegistrationBean getWatermarkConfigFilter() {
Set<String> filterUri = new HashSet<>(); Set<String> filterUri = new HashSet<>();
filterUri.add("/index");
filterUri.add("/onlinePreview"); filterUri.add("/onlinePreview");
filterUri.add("/picturesPreview"); filterUri.add("/picturesPreview");
AttributeSetFilter filter = new AttributeSetFilter(); AttributeSetFilter filter = new AttributeSetFilter();
......
...@@ -58,12 +58,14 @@ ...@@ -58,12 +58,14 @@
</h4> </h4>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<#if fileUploadDisable == false>
<div style="padding: 10px"> <div style="padding: 10px">
<form enctype="multipart/form-data" id="fileUpload"> <form enctype="multipart/form-data" id="fileUpload">
<input type="file" name="file"/> <input type="file" name="file"/>
<input type="button" id="btnSubmit" value=" 上 传 "/> <input type="button" id="btnSubmit" value=" 上 传 "/>
</form> </form>
</div> </div>
</#if>
<div> <div>
<table id="table" data-pagination="true"></table> <table id="table" data-pagination="true"></table>
</div> </div>
...@@ -250,7 +252,6 @@ ...@@ -250,7 +252,6 @@
var height = window.document.documentElement.clientHeight - 1; var height = window.document.documentElement.clientHeight - 1;
$(".loading_container").css("height", height).show(); $(".loading_container").css("height", height).show();
} }
$("#btnSubmit").click(function () { $("#btnSubmit").click(function () {
showLoadingDiv(); showLoadingDiv();
$("#fileUpload").ajaxSubmit({ $("#fileUpload").ajaxSubmit({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment