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
梁杰芳
slm-fileview
Commits
af8ddc10
Commit
af8ddc10
authored
Apr 17, 2019
by
陈精华
Committed by
kl
Apr 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文件转换编码默认根据操作系统获取,变为可选配置
文本和多媒体类型添加默认值,变为可选配置
parent
3713e6e5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
28 deletions
+18
-28
application.properties
jodconverter-web/src/main/conf/application.properties
+6
-6
ConfigRefreshComponent.java
...rc/main/java/cn/keking/config/ConfigRefreshComponent.java
+9
-4
FileUtils.java
...onverter-web/src/main/java/cn/keking/utils/FileUtils.java
+3
-18
No files found.
jodconverter-web/src/main/conf/application.properties
View file @
af8ddc10
...
@@ -27,9 +27,9 @@ spring.http.multipart.max-file-size=100MB
...
@@ -27,9 +27,9 @@ spring.http.multipart.max-file-size=100MB
#spring.redisson.address = 192.168.1.204:6379
#spring.redisson.address = 192.168.1.204:6379
#######################################可在运行时动态配置#######################################
#######################################可在运行时动态配置#######################################
#
#文本类型
#
文本类型,默认如下,可自定义添加
simText
=
txt,html,xml,java,properties,mp3,mp4
,sql
#simText = txt,html,xml,properties,md,java,py,c,cpp
,sql
#多媒体类型
#多媒体类型
,默认如下,可自定义添加
media
=
mp3,mp4,flv,
#media = mp3,wav,mp4,flv
#文件转换编码
#文件转换编码
,默认根据操作系统获取
converted.file.charset
=
GBK
#
converted.file.charset = GBK
jodconverter-web/src/main/java/cn/keking/config/ConfigRefreshComponent.java
View file @
af8ddc10
...
@@ -21,6 +21,10 @@ public class ConfigRefreshComponent {
...
@@ -21,6 +21,10 @@ public class ConfigRefreshComponent {
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ConfigRefreshComponent
.
class
);
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ConfigRefreshComponent
.
class
);
public
static
final
String
DEFAULT_TXT_TYPE
=
"txt,html,xml,properties,md,java,py,c,cpp,sql"
;
public
static
final
String
DEFAULT_MEDIA_TYPE
=
"mp3,wav,mp4,flv"
;
@PostConstruct
@PostConstruct
void
refresh
()
{
void
refresh
()
{
Thread
configRefreshThread
=
new
Thread
(
new
ConfigRefreshThread
());
Thread
configRefreshThread
=
new
Thread
(
new
ConfigRefreshThread
());
...
@@ -32,9 +36,10 @@ public class ConfigRefreshComponent {
...
@@ -32,9 +36,10 @@ public class ConfigRefreshComponent {
public
void
run
()
{
public
void
run
()
{
try
{
try
{
Properties
properties
=
new
Properties
();
Properties
properties
=
new
Properties
();
Properties
sysProperties
=
System
.
getProperties
();
String
text
;
String
text
;
String
media
;
String
media
;
String
convertedFileCharset
;
String
convertedFileCharset
=
sysProperties
.
getProperty
(
"sun.jnu.encoding"
)
;
String
[]
textArray
;
String
[]
textArray
;
String
[]
mediaArray
;
String
[]
mediaArray
;
String
homePath
=
OfficeUtils
.
getHomePath
();
String
homePath
=
OfficeUtils
.
getHomePath
();
...
@@ -43,9 +48,9 @@ public class ConfigRefreshComponent {
...
@@ -43,9 +48,9 @@ public class ConfigRefreshComponent {
while
(
true
)
{
while
(
true
)
{
BufferedReader
bufferedReader
=
new
BufferedReader
(
new
FileReader
(
configFilePath
));
BufferedReader
bufferedReader
=
new
BufferedReader
(
new
FileReader
(
configFilePath
));
properties
.
load
(
bufferedReader
);
properties
.
load
(
bufferedReader
);
text
=
properties
.
get
(
"simText"
)
==
null
?
""
:
properties
.
get
(
"simText"
).
toString
(
);
text
=
properties
.
get
Property
(
"simText"
,
DEFAULT_TXT_TYPE
);
media
=
properties
.
get
(
"media"
)
==
null
?
""
:
properties
.
get
(
"media"
).
toString
(
);
media
=
properties
.
get
Property
(
"media"
,
DEFAULT_MEDIA_TYPE
);
convertedFileCharset
=
properties
.
get
(
"converted.file.charset"
)
==
null
?
""
:
properties
.
get
(
"converted.file.charset"
).
toString
(
);
convertedFileCharset
=
properties
.
get
Property
(
"converted.file.charset"
,
convertedFileCharset
);
textArray
=
text
.
split
(
","
);
textArray
=
text
.
split
(
","
);
mediaArray
=
media
.
split
(
","
);
mediaArray
=
media
.
split
(
","
);
ConfigConstants
.
setSimText
(
textArray
);
ConfigConstants
.
setSimText
(
textArray
);
...
...
jodconverter-web/src/main/java/cn/keking/utils/FileUtils.java
View file @
af8ddc10
...
@@ -8,7 +8,6 @@ import com.google.common.collect.Lists;
...
@@ -8,7 +8,6 @@ import com.google.common.collect.Lists;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.io.*
;
import
java.io.*
;
...
@@ -32,14 +31,6 @@ public class FileUtils {
...
@@ -32,14 +31,6 @@ public class FileUtils {
String
fileDir
=
ConfigConstants
.
getFileDir
();
String
fileDir
=
ConfigConstants
.
getFileDir
();
@Value
(
"${converted.file.charset}"
)
String
charset
;
@Value
(
"${simText}"
)
String
[]
simText
;
@Value
(
"${media}"
)
String
[]
media
;
/**
/**
* 已转换过的文件集合(redis缓存)
* 已转换过的文件集合(redis缓存)
* @return
* @return
...
@@ -63,12 +54,8 @@ public class FileUtils {
...
@@ -63,12 +54,8 @@ public class FileUtils {
* @return
* @return
*/
*/
public
FileType
typeFromUrl
(
String
url
)
{
public
FileType
typeFromUrl
(
String
url
)
{
if
(
ConfigConstants
.
getSimText
()
!=
null
&&
ConfigConstants
.
getSimText
().
length
>
0
)
{
String
[]
simText
=
ConfigConstants
.
getSimText
();
simText
=
ConfigConstants
.
getSimText
();
String
[]
media
=
ConfigConstants
.
getMedia
();
}
if
(
ConfigConstants
.
getMedia
()
!=
null
&&
ConfigConstants
.
getMedia
().
length
>
0
)
{
media
=
ConfigConstants
.
getMedia
();
}
String
nonPramStr
=
url
.
substring
(
0
,
url
.
indexOf
(
"?"
)
!=
-
1
?
url
.
indexOf
(
"?"
)
:
url
.
length
());
String
nonPramStr
=
url
.
substring
(
0
,
url
.
indexOf
(
"?"
)
!=
-
1
?
url
.
indexOf
(
"?"
)
:
url
.
length
());
String
fileName
=
nonPramStr
.
substring
(
nonPramStr
.
lastIndexOf
(
"/"
)
+
1
);
String
fileName
=
nonPramStr
.
substring
(
nonPramStr
.
lastIndexOf
(
"/"
)
+
1
);
String
fileType
=
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
)
+
1
);
String
fileType
=
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
)
+
1
);
...
@@ -223,9 +210,7 @@ public class FileUtils {
...
@@ -223,9 +210,7 @@ public class FileUtils {
*/
*/
public
void
doActionConvertedFile
(
String
outFilePath
)
{
public
void
doActionConvertedFile
(
String
outFilePath
)
{
StringBuffer
sb
=
new
StringBuffer
();
StringBuffer
sb
=
new
StringBuffer
();
if
(
ConfigConstants
.
getConvertedFileCharset
()
!=
null
)
{
String
charset
=
ConfigConstants
.
getConvertedFileCharset
();
charset
=
ConfigConstants
.
getConvertedFileCharset
();
}
try
(
InputStream
inputStream
=
new
FileInputStream
(
outFilePath
);
try
(
InputStream
inputStream
=
new
FileInputStream
(
outFilePath
);
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
inputStream
,
charset
))){
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
inputStream
,
charset
))){
String
line
;
String
line
;
...
...
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