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
1060bdd0
Commit
1060bdd0
authored
Oct 17, 2019
by
陈精华
Committed by
kl
Oct 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新功能点:支持base url配置(主要用于nginx反向代理等)
parent
8c2fb2bd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
4 deletions
+33
-4
application.properties
jodconverter-web/src/main/conf/application.properties
+3
-0
ConfigConstants.java
...r-web/src/main/java/cn/keking/config/ConfigConstants.java
+10
-0
ConfigRefreshComponent.java
...rc/main/java/cn/keking/config/ConfigRefreshComponent.java
+7
-0
ChinesePathFilter.java
...eb/src/main/java/cn/keking/filters/ChinesePathFilter.java
+13
-4
No files found.
jodconverter-web/src/main/conf/application.properties
View file @
1060bdd0
...
@@ -31,6 +31,9 @@ spring.http.multipart.max-file-size=100MB
...
@@ -31,6 +31,9 @@ spring.http.multipart.max-file-size=100MB
cache.clean
=
true
cache.clean
=
true
#######################################可在运行时动态配置#######################################
#######################################可在运行时动态配置#######################################
#提供预览服务的地址,默认从请求url读,如果使用nginx等反向代理,需要手动设置
#base.url = https://file.keking.cn
#是否启用缓存
#是否启用缓存
cache.enabled
=
true
cache.enabled
=
true
...
...
jodconverter-web/src/main/java/cn/keking/config/ConfigConstants.java
View file @
1060bdd0
...
@@ -23,6 +23,7 @@ public class ConfigConstants {
...
@@ -23,6 +23,7 @@ public class ConfigConstants {
private
static
String
ftpPassword
;
private
static
String
ftpPassword
;
private
static
String
ftpControlEncoding
;
private
static
String
ftpControlEncoding
;
private
static
String
fileDir
=
OfficeUtils
.
getHomePath
()
+
File
.
separator
+
"file"
+
File
.
separator
;
private
static
String
fileDir
=
OfficeUtils
.
getHomePath
()
+
File
.
separator
+
"file"
+
File
.
separator
;
private
static
String
baseUrl
;
public
static
Boolean
isCacheEnabled
()
{
public
static
Boolean
isCacheEnabled
()
{
return
cacheEnabled
;
return
cacheEnabled
;
...
@@ -92,6 +93,15 @@ public class ConfigConstants {
...
@@ -92,6 +93,15 @@ public class ConfigConstants {
return
fileDir
;
return
fileDir
;
}
}
public
static
String
getBaseUrl
()
{
return
baseUrl
;
}
public
static
void
setBaseUrl
(
String
baseUrl
)
{
// 不以'/'结尾的,加上'/'
ConfigConstants
.
baseUrl
=
baseUrl
.
concat
(
"/"
);
}
@Value
(
"${file.dir:default}"
)
@Value
(
"${file.dir:default}"
)
public
void
setFileDir
(
String
fileDir
)
{
public
void
setFileDir
(
String
fileDir
)
{
if
(!
"default"
.
equals
(
fileDir
))
{
if
(!
"default"
.
equals
(
fileDir
))
{
...
...
jodconverter-web/src/main/java/cn/keking/config/ConfigRefreshComponent.java
View file @
1060bdd0
...
@@ -5,6 +5,7 @@ import org.artofsolving.jodconverter.office.OfficeUtils;
...
@@ -5,6 +5,7 @@ import org.artofsolving.jodconverter.office.OfficeUtils;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.StringUtils
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
...
@@ -29,6 +30,7 @@ public class ConfigRefreshComponent {
...
@@ -29,6 +30,7 @@ public class ConfigRefreshComponent {
public
static
final
String
DEFAULT_FTP_USERNAME
=
null
;
public
static
final
String
DEFAULT_FTP_USERNAME
=
null
;
public
static
final
String
DEFAULT_FTP_PASSWORD
=
null
;
public
static
final
String
DEFAULT_FTP_PASSWORD
=
null
;
public
static
final
String
DEFAULT_FTP_CONTROL_ENCODING
=
"UTF-8"
;
public
static
final
String
DEFAULT_FTP_CONTROL_ENCODING
=
"UTF-8"
;
public
static
final
String
BASE_URL
=
null
;
@PostConstruct
@PostConstruct
...
@@ -53,6 +55,7 @@ public class ConfigRefreshComponent {
...
@@ -53,6 +55,7 @@ public class ConfigRefreshComponent {
String
ftpPassword
;
String
ftpPassword
;
String
ftpControlEncoding
;
String
ftpControlEncoding
;
String
configFilePath
=
OfficeUtils
.
getCustomizedConfigPath
();
String
configFilePath
=
OfficeUtils
.
getCustomizedConfigPath
();
String
baseUlr
;
while
(
true
)
{
while
(
true
)
{
FileReader
fileReader
=
new
FileReader
(
configFilePath
);
FileReader
fileReader
=
new
FileReader
(
configFilePath
);
BufferedReader
bufferedReader
=
new
BufferedReader
(
fileReader
);
BufferedReader
bufferedReader
=
new
BufferedReader
(
fileReader
);
...
@@ -67,6 +70,7 @@ public class ConfigRefreshComponent {
...
@@ -67,6 +70,7 @@ public class ConfigRefreshComponent {
ftpControlEncoding
=
properties
.
getProperty
(
"ftp.control.encoding"
,
DEFAULT_FTP_CONTROL_ENCODING
);
ftpControlEncoding
=
properties
.
getProperty
(
"ftp.control.encoding"
,
DEFAULT_FTP_CONTROL_ENCODING
);
textArray
=
text
.
split
(
","
);
textArray
=
text
.
split
(
","
);
mediaArray
=
media
.
split
(
","
);
mediaArray
=
media
.
split
(
","
);
baseUlr
=
properties
.
getProperty
(
"base.url"
,
null
);
ConfigConstants
.
setCacheEnabled
(
cacheEnabled
);
ConfigConstants
.
setCacheEnabled
(
cacheEnabled
);
ConfigConstants
.
setSimText
(
textArray
);
ConfigConstants
.
setSimText
(
textArray
);
ConfigConstants
.
setMedia
(
mediaArray
);
ConfigConstants
.
setMedia
(
mediaArray
);
...
@@ -75,6 +79,9 @@ public class ConfigRefreshComponent {
...
@@ -75,6 +79,9 @@ public class ConfigRefreshComponent {
ConfigConstants
.
setFtpUsername
(
ftpUsername
);
ConfigConstants
.
setFtpUsername
(
ftpUsername
);
ConfigConstants
.
setFtpPassword
(
ftpPassword
);
ConfigConstants
.
setFtpPassword
(
ftpPassword
);
ConfigConstants
.
setFtpControlEncoding
(
ftpControlEncoding
);
ConfigConstants
.
setFtpControlEncoding
(
ftpControlEncoding
);
if
(
baseUlr
!=
null
&&
!
StringUtils
.
isEmpty
(
baseUlr
))
{
ConfigConstants
.
setBaseUrl
(
baseUlr
);
}
bufferedReader
.
close
();
bufferedReader
.
close
();
fileReader
.
close
();
fileReader
.
close
();
Thread
.
sleep
(
1000L
);
Thread
.
sleep
(
1000L
);
...
...
jodconverter-web/src/main/java/cn/keking/filters/ChinesePathFilter.java
View file @
1060bdd0
package
cn
.
keking
.
filters
;
package
cn
.
keking
.
filters
;
import
cn.keking.config.ConfigConstants
;
import
org.springframework.util.StringUtils
;
import
javax.servlet.*
;
import
javax.servlet.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -19,10 +22,16 @@ public class ChinesePathFilter implements Filter {
...
@@ -19,10 +22,16 @@ public class ChinesePathFilter implements Filter {
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
request
.
setCharacterEncoding
(
"UTF-8"
);
request
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
StringBuilder
pathBuilder
=
new
StringBuilder
();
String
baseUrl
;
pathBuilder
.
append
(
request
.
getScheme
()).
append
(
"://"
).
append
(
request
.
getServerName
()).
append
(
":"
)
if
(
ConfigConstants
.
getBaseUrl
()
!=
null
)
{
.
append
(
request
.
getServerPort
()).
append
(((
HttpServletRequest
)
request
).
getContextPath
()).
append
(
"/"
);
baseUrl
=
ConfigConstants
.
getBaseUrl
();
request
.
setAttribute
(
"baseUrl"
,
pathBuilder
.
toString
());
}
else
{
StringBuilder
pathBuilder
=
new
StringBuilder
();
pathBuilder
.
append
(
request
.
getScheme
()).
append
(
"://"
).
append
(
request
.
getServerName
()).
append
(
":"
)
.
append
(
request
.
getServerPort
()).
append
(((
HttpServletRequest
)
request
).
getContextPath
()).
append
(
"/"
);
baseUrl
=
pathBuilder
.
toString
();
}
request
.
setAttribute
(
"baseUrl"
,
baseUrl
);
chain
.
doFilter
(
request
,
response
);
chain
.
doFilter
(
request
,
response
);
}
}
...
...
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