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
6f2001b8
Commit
6f2001b8
authored
Mar 25, 2018
by
chenkailing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.修复不支持文件类型提示时抛异常的问题
2.添加多媒体文件预览支持,如mp4,mp3等文件
parent
378920b7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
98 additions
and
24 deletions
+98
-24
FileType.java
jodconverter-web/src/main/java/cn/keking/model/FileType.java
+2
-1
MediaFilePreviewImpl.java
...ain/java/cn/keking/service/impl/MediaFilePreviewImpl.java
+27
-0
OtherFilePreviewImpl.java
...ain/java/cn/keking/service/impl/OtherFilePreviewImpl.java
+9
-0
SimTextFilePreviewImpl.java
...n/java/cn/keking/service/impl/SimTextFilePreviewImpl.java
+1
-0
FileUtils.java
...onverter-web/src/main/java/cn/keking/utils/FileUtils.java
+6
-0
application-dev.properties
...nverter-web/src/main/resources/application-dev.properties
+11
-10
application-prod.properties
...verter-web/src/main/resources/application-prod.properties
+9
-7
application-uat.properties
...nverter-web/src/main/resources/application-uat.properties
+7
-6
plyr.css
jodconverter-web/src/main/resources/static/plyr/plyr.css
+0
-0
plyr.js
jodconverter-web/src/main/resources/static/plyr/plyr.js
+0
-0
plyr.svg
jodconverter-web/src/main/resources/static/plyr/plyr.svg
+2
-0
media.ftl
jodconverter-web/src/main/resources/web/media.ftl
+24
-0
No files found.
jodconverter-web/src/main/java/cn/keking/model/FileType.java
View file @
6f2001b8
...
...
@@ -10,7 +10,8 @@ public enum FileType {
office
(
"officeFilePreviewImpl"
),
simText
(
"simTextFilePreviewImpl"
),
pdf
(
"pdfFilePreviewImpl"
),
other
(
"otherFilePreviewImpl"
);
other
(
"otherFilePreviewImpl"
),
media
(
"mediaFilePreviewImpl"
);
private
String
instanceName
;
FileType
(
String
instanceName
){
...
...
jodconverter-web/src/main/java/cn/keking/service/impl/MediaFilePreviewImpl.java
0 → 100644
View file @
6f2001b8
package
cn
.
keking
.
service
.
impl
;
import
cn.keking.service.FilePreview
;
import
cn.keking.utils.FileUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.ui.Model
;
/**
* @author : kl
* @authorboke : kailing.pub
* @create : 2018-03-25 上午11:58
* @description:
**/
@Service
public
class
MediaFilePreviewImpl
implements
FilePreview
{
@Autowired
FileUtils
fileUtils
;
@Override
public
String
filePreviewHandle
(
String
url
,
Model
model
)
{
model
.
addAttribute
(
"mediaUrl"
,
url
);
return
"media"
;
}
}
jodconverter-web/src/main/java/cn/keking/service/impl/OtherFilePreviewImpl.java
View file @
6f2001b8
package
cn
.
keking
.
service
.
impl
;
import
cn.keking.model.FileAttribute
;
import
cn.keking.service.FilePreview
;
import
cn.keking.utils.FileUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.ui.Model
;
...
...
@@ -10,8 +13,14 @@ import org.springframework.ui.Model;
*/
@Service
public
class
OtherFilePreviewImpl
implements
FilePreview
{
@Autowired
FileUtils
fileUtils
;
@Override
public
String
filePreviewHandle
(
String
url
,
Model
model
)
{
FileAttribute
fileAttribute
=
fileUtils
.
getFileAttribute
(
url
);
model
.
addAttribute
(
"fileType"
,
fileAttribute
.
getSuffix
());
model
.
addAttribute
(
"msg"
,
"系统还不支持该格式文件的在线预览,"
+
"如有需要请按下方显示的邮箱地址联系系统维护人员"
);
return
"fileNotSupported"
;
...
...
jodconverter-web/src/main/java/cn/keking/service/impl/SimTextFilePreviewImpl.java
View file @
6f2001b8
...
...
@@ -30,6 +30,7 @@ public class SimTextFilePreviewImpl implements FilePreview{
ReturnResponse
<
String
>
response
=
simTextUtil
.
readSimText
(
decodedUrl
,
fileName
);
if
(
0
!=
response
.
getCode
())
{
model
.
addAttribute
(
"msg"
,
response
.
getMsg
());
model
.
addAttribute
(
"fileType"
,
fileAttribute
.
getSuffix
());
return
"fileNotSupported"
;
}
model
.
addAttribute
(
"ordinaryUrl"
,
response
.
getMsg
());
...
...
jodconverter-web/src/main/java/cn/keking/utils/FileUtils.java
View file @
6f2001b8
...
...
@@ -40,6 +40,9 @@ public class FileUtils {
@Value
(
"${simText}"
)
String
[]
simText
;
@Value
(
"${media}"
)
String
[]
media
;
/**
* 已转换过的文件集合(redis缓存)
* @return
...
...
@@ -80,6 +83,9 @@ public class FileUtils {
if
(
Arrays
.
asList
(
simText
).
contains
(
fileType
.
toLowerCase
()))
{
return
FileType
.
simText
;
}
if
(
Arrays
.
asList
(
media
).
contains
(
fileType
.
toLowerCase
()))
{
return
FileType
.
media
;
}
if
(
"pdf"
.
equalsIgnoreCase
(
fileType
)){
return
FileType
.
pdf
;
}
...
...
jodconverter-web/src/main/resources/application-dev.properties
View file @
6f2001b8
#=============================================#spring Redisson
配置
#===================================#
spring.redisson.address
=
1
92.168.1.204
:6379
##
资源映射路径(因为jar方式运行的原因
)
file.dir
=
C:
\\
Users
\\
yudian
\\
Desktop
\\
dev
\\
#=============================================#spring Redisson
����#=
==================================#
spring.redisson.address
=
1
27.0.0.1
:6379
##
��Դӳ��·��(��Ϊjar��ʽ���е�ԭ��)
file.dir
=
/Users/chenkailing/test/
spring.resources.static-locations
=
classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:${file.dir}
## openoffice
相关配置
office.home
=
C:
\\
Program Files (x86)
\\
OpenOffice 4
## openoffice
�������
office.home
=
/Applications/LibreOffice.app/Contents
server.tomcat.uri-encoding
=
UTF-8
converted.file.charset
=
GBK
#======================================#
文件上传限制
#======================================#
#======================================#
�ļ��ϴ�����#===
===================================#
spring.http.multipart.max-file-size
=
100MB
spring.http.multipart.max-request-size
=
100MB
## 支持的类文本格式的文件类型
simText
=
txt,html,xml,java,properties,mp3,mp4,sql
\ No newline at end of file
## ֧�ֵ����ı���ʽ���ļ�����
simText
=
txt,html,xml,java,properties,sql
media
=
mp3,mp4,flv,rmvb
\ No newline at end of file
jodconverter-web/src/main/resources/application-prod.properties
View file @
6f2001b8
#=============================================#spring Redisson
配置
#===================================#
#=============================================#spring Redisson
����#=
==================================#
spring.redisson.address
=
10.19.140.7:6379
spring.redisson.database
=
0
##
资源映射路径(因为jar方式运行的原因
)
##
��Դӳ��·��(��Ϊjar��ʽ���е�ԭ��)
file.dir
=
/data/file-preview/convertedFile/
spring.resources.static-locations
=
classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:${file.dir}
## openoffice
相关配置
## openoffice
�������
office.home
=
/opt/openoffice4
##
编码设置
##
��������
server.tomcat.uri-encoding
=
utf-8
converted.file.charset
=
utf-8
##
文件上传最大值
##
�ļ��ϴ����ֵ
spring.http.multipart.max-file-size
=
100MB
## 支
持的类文本格式的文件类型
simText
=
txt,html,xml,java,properties,sql,js,md,json,conf,ini,vue,php,py,bat,gitignore,log,htm,
mp3,mp4,
css,cnf
## ֧
�ֵ����ı���ʽ���ļ�����
simText
=
txt,html,xml,java,properties,sql,js,md,json,conf,ini,vue,php,py,bat,gitignore,log,htm,css,cnf
media
=
mp3,mp4,flv
\ No newline at end of file
jodconverter-web/src/main/resources/application-uat.properties
View file @
6f2001b8
#=============================================#spring Redisson
配置
#===================================#
#=============================================#spring Redisson
����#=
==================================#
spring.redisson.address
=
192.168.1.204:6379
spring.redisson.database
=
3
##
资源映射路径(因为jar方式运行的原因
)
##
��Դӳ��·��(��Ϊjar��ʽ���е�ԭ��)
file.dir
=
/data/filepreview/
spring.resources.static-locations
=
classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:${file.dir}
## openoffice
相关配置
## openoffice
�������
openOfficePath
=
123
office.home
=
/opt/openoffice4
server.tomcat.uri-encoding
=
utf-8
converted.file.charset
=
utf-8
spring.http.multipart.max-file-size
=
100MB
## 支持的类文本格式的文件类型
simText
=
txt,html,xml,java,properties,sql,js,md,json,conf,ini,vue,php,py,bat,gitignore,log,htm,mp3,mp4,css,cnf
\ No newline at end of file
## ֧�ֵ����ı���ʽ���ļ�����
simText
=
txt,html,xml,java,properties,sql,js,md,json,conf,ini,vue,php,py,bat,gitignore,log,htm,css,cnf
media
=
mp3,mp4,flv
\ No newline at end of file
jodconverter-web/src/main/resources/static/plyr/plyr.css
0 → 100755
View file @
6f2001b8
This diff is collapsed.
Click to expand it.
jodconverter-web/src/main/resources/static/plyr/plyr.js
0 → 100755
View file @
6f2001b8
This diff is collapsed.
Click to expand it.
jodconverter-web/src/main/resources/static/plyr/plyr.svg
0 → 100755
View file @
6f2001b8
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
xmlns=
"http://www.w3.org/2000/svg"
><symbol
id=
"plyr-captions-off"
viewBox=
"0 0 18 18"
><path
d=
"M1 1c-.6 0-1 .4-1 1v11c0 .6.4 1 1 1h4.6l2.7 2.7c.2.2.4.3.7.3.3 0 .5-.1.7-.3l2.7-2.7H17c.6 0 1-.4 1-1V2c0-.6-.4-1-1-1H1zm4.52 10.15c1.99 0 3.01-1.32 3.28-2.41l-1.29-.39c-.19.66-.78 1.45-1.99 1.45-1.14 0-2.2-.83-2.2-2.34 0-1.61 1.12-2.37 2.18-2.37 1.23 0 1.78.75 1.95 1.43l1.3-.41C8.47 4.96 7.46 3.76 5.5 3.76c-1.9 0-3.61 1.44-3.61 3.7 0 2.26 1.65 3.69 3.63 3.69zm7.57 0c1.99 0 3.01-1.32 3.28-2.41l-1.29-.39c-.19.66-.78 1.45-1.99 1.45-1.14 0-2.2-.83-2.2-2.34 0-1.61 1.12-2.37 2.18-2.37 1.23 0 1.78.75 1.95 1.43l1.3-.41c-.28-1.15-1.29-2.35-3.25-2.35-1.9 0-3.61 1.44-3.61 3.7 0 2.26 1.65 3.69 3.63 3.69z"
fill-rule=
"evenodd"
fill-opacity=
".5"
/></symbol><symbol
id=
"plyr-captions-on"
viewBox=
"0 0 18 18"
><path
d=
"M1 1c-.6 0-1 .4-1 1v11c0 .6.4 1 1 1h4.6l2.7 2.7c.2.2.4.3.7.3.3 0 .5-.1.7-.3l2.7-2.7H17c.6 0 1-.4 1-1V2c0-.6-.4-1-1-1H1zm4.52 10.15c1.99 0 3.01-1.32 3.28-2.41l-1.29-.39c-.19.66-.78 1.45-1.99 1.45-1.14 0-2.2-.83-2.2-2.34 0-1.61 1.12-2.37 2.18-2.37 1.23 0 1.78.75 1.95 1.43l1.3-.41C8.47 4.96 7.46 3.76 5.5 3.76c-1.9 0-3.61 1.44-3.61 3.7 0 2.26 1.65 3.69 3.63 3.69zm7.57 0c1.99 0 3.01-1.32 3.28-2.41l-1.29-.39c-.19.66-.78 1.45-1.99 1.45-1.14 0-2.2-.83-2.2-2.34 0-1.61 1.12-2.37 2.18-2.37 1.23 0 1.78.75 1.95 1.43l1.3-.41c-.28-1.15-1.29-2.35-3.25-2.35-1.9 0-3.61 1.44-3.61 3.7 0 2.26 1.65 3.69 3.63 3.69z"
fill-rule=
"evenodd"
/></symbol><symbol
id=
"plyr-enter-fullscreen"
viewBox=
"0 0 18 18"
><path
d=
"M10 3h3.6l-4 4L11 8.4l4-4V8h2V1h-7zM7 9.6l-4 4V10H1v7h7v-2H4.4l4-4z"
/></symbol><symbol
id=
"plyr-exit-fullscreen"
viewBox=
"0 0 18 18"
><path
d=
"M1 12h3.6l-4 4L2 17.4l4-4V17h2v-7H1zM16 .6l-4 4V1h-2v7h7V6h-3.6l4-4z"
/></symbol><symbol
id=
"plyr-fast-forward"
viewBox=
"0 0 18 18"
><path
d=
"M7.875 7.171L0 1v16l7.875-6.171V17L18 9 7.875 1z"
/></symbol><symbol
id=
"plyr-muted"
viewBox=
"0 0 18 18"
><path
d=
"M12.4 12.5l2.1-2.1 2.1 2.1 1.4-1.4L15.9 9 18 6.9l-1.4-1.4-2.1 2.1-2.1-2.1L11 6.9 13.1 9 11 11.1zM3.786 6.008H.714C.286 6.008 0 6.31 0 6.76v4.512c0 .452.286.752.714.752h3.072l4.071 3.858c.5.3 1.143 0 1.143-.602V2.752c0-.601-.643-.977-1.143-.601L3.786 6.008z"
/></symbol><symbol
id=
"plyr-pause"
viewBox=
"0 0 18 18"
><path
d=
"M6 1H3c-.6 0-1 .4-1 1v14c0 .6.4 1 1 1h3c.6 0 1-.4 1-1V2c0-.6-.4-1-1-1zM12 1c-.6 0-1 .4-1 1v14c0 .6.4 1 1 1h3c.6 0 1-.4 1-1V2c0-.6-.4-1-1-1h-3z"
/></symbol><symbol
id=
"plyr-play"
viewBox=
"0 0 18 18"
><path
d=
"M15.562 8.1L3.87.225C3.052-.337 2 .225 2 1.125v15.75c0 .9 1.052 1.462 1.87.9L15.563 9.9c.584-.45.584-1.35 0-1.8z"
/></symbol><symbol
id=
"plyr-restart"
viewBox=
"0 0 18 18"
><path
d=
"M9.7 1.2l.7 6.4 2.1-2.1c1.9 1.9 1.9 5.1 0 7-.9 1-2.2 1.5-3.5 1.5-1.3 0-2.6-.5-3.5-1.5-1.9-1.9-1.9-5.1 0-7 .6-.6 1.4-1.1 2.3-1.3l-.6-1.9C6 2.6 4.9 3.2 4 4.1 1.3 6.8 1.3 11.2 4 14c1.3 1.3 3.1 2 4.9 2 1.9 0 3.6-.7 4.9-2 2.7-2.7 2.7-7.1 0-9.9L16 1.9l-6.3-.7z"
/></symbol><symbol
id=
"plyr-rewind"
viewBox=
"0 0 18 18"
><path
d=
"M10.125 1L0 9l10.125 8v-6.171L18 17V1l-7.875 6.171z"
/></symbol><symbol
id=
"plyr-volume"
viewBox=
"0 0 18 18"
><path
d=
"M15.6 3.3c-.4-.4-1-.4-1.4 0-.4.4-.4 1 0 1.4C15.4 5.9 16 7.4 16 9c0 1.6-.6 3.1-1.8 4.3-.4.4-.4 1 0 1.4.2.2.5.3.7.3.3 0 .5-.1.7-.3C17.1 13.2 18 11.2 18 9s-.9-4.2-2.4-5.7z"
/><path
d=
"M11.282 5.282a.909.909 0 0 0 0 1.316c.735.735.995 1.458.995 2.402 0 .936-.425 1.917-.995 2.487a.909.909 0 0 0 0 1.316c.145.145.636.262 1.018.156a.725.725 0 0 0 .298-.156C13.773 11.733 14.13 10.16 14.13 9c0-.17-.002-.34-.011-.51-.053-.992-.319-2.005-1.522-3.208a.909.909 0 0 0-1.316 0zM3.786 6.008H.714C.286 6.008 0 6.31 0 6.76v4.512c0 .452.286.752.714.752h3.072l4.071 3.858c.5.3 1.143 0 1.143-.602V2.752c0-.601-.643-.977-1.143-.601L3.786 6.008z"
/></symbol></svg>
\ No newline at end of file
jodconverter-web/src/main/resources/web/media.ftl
0 → 100644
View file @
6f2001b8
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
>
<title>
多媒体文件预览
</title>
<link
rel=
"stylesheet"
href=
"plyr/plyr.css"
>
</head>
<style>
body
{
background-color
:
#262626
}
.m
{
margin-left
:
auto
;
margin-right
:
auto
;
width
:
640px
;
margin-top
:
100px
;
}
</style>
<body>
<div
class=
"m"
>
<video
controls
>
<source
src=
"${mediaUrl}"
>
</video>
</div>
<script
src=
"plyr/plyr.js"
></script>
<script>
plyr
.
setup
();
</script>
</body>
</html>
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