Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
slm-fileview
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jenkins
slm-fileview
Commits
fcdefa45
Commit
fcdefa45
authored
Jul 06, 2021
by
陈精华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新功能点:首页文件上传功能可通过配置实时开启或禁用
parent
dc50a460
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
8 deletions
+32
-8
application.properties
server/src/main/config/application.properties
+2
-0
ConfigConstants.java
server/src/main/java/cn/keking/config/ConfigConstants.java
+14
-0
ConfigRefreshComponent.java
...rc/main/java/cn/keking/config/ConfigRefreshComponent.java
+3
-0
FileController.java
...rc/main/java/cn/keking/web/controller/FileController.java
+3
-0
AttributeSetFilter.java
...rc/main/java/cn/keking/web/filter/AttributeSetFilter.java
+1
-1
FilterConfiguration.java
...c/main/java/cn/keking/web/filter/FilterConfiguration.java
+1
-0
index.ftl
server/src/main/resources/web/index.ftl
+8
-7
No files found.
server/src/main/config/application.properties
View file @
fcdefa45
...
...
@@ -67,6 +67,8 @@ office.preview.switch.disabled = ${KK_OFFICE_PREVIEW_SWITCH_DISABLED:false}
#是否禁止下载转换生成的pdf文件
pdf.download.disable
=
${KK_PDF_DOWNLOAD_DISABLE:true}
#是否禁用首页文件上传
file.upload.disable
=
${KK_FILE_UPLOAD_ENABLED:false}
#预览源为FTP时 FTP用户名,可在ftp url后面加参数ftp.username=ftpuser指定,不指定默认用配置的
ftp.username
=
${KK_FTP_USERNAME:ftpuser}
...
...
server/src/main/java/cn/keking/config/ConfigConstants.java
View file @
fcdefa45
...
...
@@ -35,6 +35,7 @@ public class ConfigConstants {
private
static
String
fileDir
=
ConfigUtils
.
getHomePath
()
+
File
.
separator
+
"file"
+
File
.
separator
;
private
static
CopyOnWriteArraySet
<
String
>
trustHostSet
;
private
static
String
pdfDownloadDisable
;
private
static
Boolean
fileUploadDisable
;
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"
;
...
...
@@ -48,6 +49,7 @@ public class ConfigConstants {
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
final
String
DEFAULT_FILE_UPLOAD_DISABLE
=
"false"
;
public
static
Boolean
isCacheEnabled
()
{
...
...
@@ -250,4 +252,16 @@ public class ConfigConstants {
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
;
}
}
server/src/main/java/cn/keking/config/ConfigRefreshComponent.java
View file @
fcdefa45
...
...
@@ -48,6 +48,7 @@ public class ConfigRefreshComponent {
String
baseUrl
;
String
trustHost
;
String
pdfDownloadDisable
;
boolean
fileUploadDisable
;
while
(
true
)
{
FileReader
fileReader
=
new
FileReader
(
configFilePath
);
BufferedReader
bufferedReader
=
new
BufferedReader
(
fileReader
);
...
...
@@ -66,6 +67,7 @@ public class ConfigRefreshComponent {
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
);
fileUploadDisable
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
"file.upload.disable"
,
ConfigConstants
.
DEFAULT_FILE_UPLOAD_DISABLE
));
ConfigConstants
.
setCacheEnabledValueValue
(
cacheEnabled
);
ConfigConstants
.
setSimTextValue
(
textArray
);
ConfigConstants
.
setMediaValue
(
mediaArray
);
...
...
@@ -77,6 +79,7 @@ public class ConfigRefreshComponent {
ConfigConstants
.
setTrustHostValue
(
trustHost
);
ConfigConstants
.
setOfficePreviewSwitchDisabledValue
(
officePreviewSwitchDisabled
);
ConfigConstants
.
setPdfDownloadDisableValue
(
pdfDownloadDisable
);
ConfigConstants
.
setFileUploadDisableValue
(
fileUploadDisable
);
setWatermarkConfig
(
properties
);
bufferedReader
.
close
();
fileReader
.
close
();
...
...
server/src/main/java/cn/keking/web/controller/FileController.java
View file @
fcdefa45
...
...
@@ -35,6 +35,9 @@ public class FileController {
@RequestMapping
(
value
=
"fileUpload"
,
method
=
RequestMethod
.
POST
)
public
String
fileUpload
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
JsonProcessingException
{
if
(
ConfigConstants
.
getFileUploadDisable
())
{
return
new
ObjectMapper
().
writeValueAsString
(
ReturnResponse
.
failure
(
"文件传接口已禁用"
));
}
// 获取文件名
String
fileName
=
file
.
getOriginalFilename
();
//判断是否为IE浏览器的文件名,IE浏览器下文件名会带有盘符信息
...
...
server/src/main/java/cn/keking/web/filter/AttributeSetFilter.java
View file @
fcdefa45
...
...
@@ -34,7 +34,7 @@ public class AttributeSetFilter implements Filter {
request
.
setAttribute
(
"pdfDownloadDisable"
,
ConfigConstants
.
getPdfDownloadDisable
());
request
.
setAttribute
(
"fileKey"
,
httpRequest
.
getParameter
(
"fileKey"
));
request
.
setAttribute
(
"switchDisabled"
,
ConfigConstants
.
getOfficePreviewSwitchDisabled
());
request
.
setAttribute
(
"fileUploadDisable"
,
ConfigConstants
.
getFileUploadDisable
());
}
/**
...
...
server/src/main/java/cn/keking/web/filter/FilterConfiguration.java
View file @
fcdefa45
...
...
@@ -53,6 +53,7 @@ public class FilterConfiguration {
@Bean
public
FilterRegistrationBean
getWatermarkConfigFilter
()
{
Set
<
String
>
filterUri
=
new
HashSet
<>();
filterUri
.
add
(
"/index"
);
filterUri
.
add
(
"/onlinePreview"
);
filterUri
.
add
(
"/picturesPreview"
);
AttributeSetFilter
filter
=
new
AttributeSetFilter
();
...
...
server/src/main/resources/web/index.ftl
View file @
fcdefa45
...
...
@@ -58,12 +58,14 @@
</h4>
</div>
<div
class=
"panel-body"
>
<div
style=
"padding: 10px"
>
<form
enctype=
"multipart/form-data"
id=
"fileUpload"
>
<input
type=
"file"
name=
"file"
/>
<input
type=
"button"
id=
"btnSubmit"
value=
" 上 传 "
/>
</form>
</div>
<
#
if
fileUploadDisable =
=
false
>
<div
style=
"padding: 10px"
>
<form
enctype=
"multipart/form-data"
id=
"fileUpload"
>
<input
type=
"file"
name=
"file"
/>
<input
type=
"button"
id=
"btnSubmit"
value=
" 上 传 "
/>
</form>
</div>
</
#
if>
<div>
<table
id=
"table"
data-pagination=
"true"
></table>
</div>
...
...
@@ -250,7 +252,6 @@
var
height
=
window
.
document
.
documentElement
.
clientHeight
-
1
;
$
(
".loading_container"
).
css
(
"height"
,
height
).
show
();
}
$
(
"#btnSubmit"
).
click
(
function
()
{
showLoadingDiv
();
$
(
"#fileUpload"
).
ajaxSubmit
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment