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
c16116c7
Commit
c16116c7
authored
May 19, 2020
by
陈精华
Committed by
kl
May 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化:视频文件预览支持FTP
parent
1a4748bb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
3 deletions
+30
-3
MediaFilePreviewImpl.java
...ain/java/cn/keking/service/impl/MediaFilePreviewImpl.java
+27
-0
FileUtils.java
...onverter-web/src/main/java/cn/keking/utils/FileUtils.java
+3
-3
No files found.
jodconverter-web/src/main/java/cn/keking/service/impl/MediaFilePreviewImpl.java
View file @
c16116c7
package
cn
.
keking
.
service
.
impl
;
import
cn.keking.model.FileAttribute
;
import
cn.keking.model.ReturnResponse
;
import
cn.keking.service.FilePreview
;
import
cn.keking.utils.DownloadUtils
;
import
cn.keking.utils.FileUtils
;
import
cn.keking.web.filter.BaseUrlFilter
;
import
org.springframework.stereotype.Service
;
import
org.springframework.ui.Model
;
/**
...
...
@@ -13,8 +17,31 @@ import org.springframework.ui.Model;
@Service
public
class
MediaFilePreviewImpl
implements
FilePreview
{
private
final
DownloadUtils
downloadUtils
;
private
final
FileUtils
fileUtils
;
public
MediaFilePreviewImpl
(
DownloadUtils
downloadUtils
,
FileUtils
fileUtils
)
{
this
.
downloadUtils
=
downloadUtils
;
this
.
fileUtils
=
fileUtils
;
}
@Override
public
String
filePreviewHandle
(
String
url
,
Model
model
,
FileAttribute
fileAttribute
)
{
// 不是http开头,浏览器不能直接访问,需下载到本地
if
(
url
!=
null
&&
!
url
.
toLowerCase
().
startsWith
(
"http"
))
{
ReturnResponse
<
String
>
response
=
downloadUtils
.
downLoad
(
fileAttribute
,
fileAttribute
.
getName
());
if
(
0
!=
response
.
getCode
())
{
model
.
addAttribute
(
"fileType"
,
fileAttribute
.
getSuffix
());
model
.
addAttribute
(
"msg"
,
response
.
getMsg
());
return
"fileNotSupported"
;
}
else
{
model
.
addAttribute
(
"mediaUrl"
,
BaseUrlFilter
.
getBaseUrl
()
+
fileUtils
.
getRelativePath
(
response
.
getContent
()));
}
}
else
{
model
.
addAttribute
(
"mediaUrl"
,
url
);
}
model
.
addAttribute
(
"mediaUrl"
,
url
);
String
suffix
=
fileAttribute
.
getSuffix
();
if
(
"flv"
.
equalsIgnoreCase
(
suffix
))
{
...
...
jodconverter-web/src/main/java/cn/keking/utils/FileUtils.java
View file @
c16116c7
...
...
@@ -24,7 +24,9 @@ import java.util.Map;
@Component
public
class
FileUtils
{
public
static
final
String
DEFAULT_CONVERTER_CHARSET
=
System
.
getProperty
(
"sun.jnu.encoding"
);
private
static
final
String
DEFAULT_CONVERTER_CHARSET
=
System
.
getProperty
(
"sun.jnu.encoding"
);
private
final
String
fileDir
=
ConfigConstants
.
getFileDir
();
private
final
CacheService
cacheService
;
...
...
@@ -32,8 +34,6 @@ public class FileUtils {
this
.
cacheService
=
cacheService
;
}
String
fileDir
=
ConfigConstants
.
getFileDir
();
/**
* @return 已转换过的文件集合(缓存)
*/
...
...
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