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
5196536b
Commit
5196536b
authored
May 14, 2020
by
陈精华
Committed by
kl
May 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复:修复预览ftp时,图片图片、pdf预览异常
parent
59ac8eff
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
5 deletions
+43
-5
PdfFilePreviewImpl.java
.../main/java/cn/keking/service/impl/PdfFilePreviewImpl.java
+14
-1
PictureFilePreviewImpl.java
...n/java/cn/keking/service/impl/PictureFilePreviewImpl.java
+24
-4
picture.ftl
jodconverter-web/src/main/resources/web/picture.ftl
+5
-0
No files found.
jodconverter-web/src/main/java/cn/keking/service/impl/PdfFilePreviewImpl.java
View file @
5196536b
...
@@ -39,7 +39,6 @@ public class PdfFilePreviewImpl implements FilePreview{
...
@@ -39,7 +39,6 @@ public class PdfFilePreviewImpl implements FilePreview{
String
fileName
=
fileAttribute
.
getName
();
String
fileName
=
fileAttribute
.
getName
();
String
officePreviewType
=
model
.
asMap
().
get
(
"officePreviewType"
)
==
null
?
ConfigConstants
.
getOfficePreviewType
()
:
model
.
asMap
().
get
(
"officePreviewType"
).
toString
();
String
officePreviewType
=
model
.
asMap
().
get
(
"officePreviewType"
)
==
null
?
ConfigConstants
.
getOfficePreviewType
()
:
model
.
asMap
().
get
(
"officePreviewType"
).
toString
();
String
baseUrl
=
BaseUrlFilter
.
getBaseUrl
();
String
baseUrl
=
BaseUrlFilter
.
getBaseUrl
();
model
.
addAttribute
(
"pdfUrl"
,
url
);
String
pdfName
=
fileName
.
substring
(
0
,
fileName
.
lastIndexOf
(
"."
)
+
1
)
+
"pdf"
;
String
pdfName
=
fileName
.
substring
(
0
,
fileName
.
lastIndexOf
(
"."
)
+
1
)
+
"pdf"
;
String
outFilePath
=
fileDir
+
pdfName
;
String
outFilePath
=
fileDir
+
pdfName
;
if
(
OfficeFilePreviewImpl
.
OFFICE_PREVIEW_TYPE_IMAGE
.
equals
(
officePreviewType
)
||
OfficeFilePreviewImpl
.
OFFICE_PREVIEW_TYPE_ALLIMAGES
.
equals
(
officePreviewType
))
{
if
(
OfficeFilePreviewImpl
.
OFFICE_PREVIEW_TYPE_IMAGE
.
equals
(
officePreviewType
)
||
OfficeFilePreviewImpl
.
OFFICE_PREVIEW_TYPE_ALLIMAGES
.
equals
(
officePreviewType
))
{
...
@@ -64,6 +63,20 @@ public class PdfFilePreviewImpl implements FilePreview{
...
@@ -64,6 +63,20 @@ public class PdfFilePreviewImpl implements FilePreview{
}
else
{
}
else
{
return
"picture"
;
return
"picture"
;
}
}
}
else
{
// 不是http开头,浏览器不能直接访问,需下载到本地
if
(
url
!=
null
&&
!
url
.
toLowerCase
().
startsWith
(
"http"
))
{
ReturnResponse
<
String
>
response
=
downloadUtils
.
downLoad
(
fileAttribute
,
pdfName
);
if
(
0
!=
response
.
getCode
())
{
model
.
addAttribute
(
"fileType"
,
suffix
);
model
.
addAttribute
(
"msg"
,
response
.
getMsg
());
return
"fileNotSupported"
;
}
else
{
model
.
addAttribute
(
"pdfUrl"
,
fileUtils
.
getRelativePath
(
response
.
getContent
()));
}
}
else
{
model
.
addAttribute
(
"pdfUrl"
,
url
);
}
}
}
return
"pdf"
;
return
"pdf"
;
}
}
...
...
jodconverter-web/src/main/java/cn/keking/service/impl/PictureFilePreviewImpl.java
View file @
5196536b
package
cn
.
keking
.
service
.
impl
;
package
cn
.
keking
.
service
.
impl
;
import
cn.keking.config.ConfigConstants
;
import
cn.keking.model.FileAttribute
;
import
cn.keking.model.FileAttribute
;
import
cn.keking.model.ReturnResponse
;
import
cn.keking.service.FilePreview
;
import
cn.keking.service.FilePreview
;
import
cn.keking.utils.DownloadUtils
;
import
cn.keking.utils.FileUtils
;
import
cn.keking.utils.FileUtils
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -21,18 +24,35 @@ public class PictureFilePreviewImpl implements FilePreview {
...
@@ -21,18 +24,35 @@ public class PictureFilePreviewImpl implements FilePreview {
@Autowired
@Autowired
FileUtils
fileUtils
;
FileUtils
fileUtils
;
@Autowired
DownloadUtils
downloadUtils
;
@Override
@Override
public
String
filePreviewHandle
(
String
url
,
Model
model
,
FileAttribute
fileAttribute
)
{
public
String
filePreviewHandle
(
String
url
,
Model
model
,
FileAttribute
fileAttribute
)
{
String
fileKey
=
(
String
)
RequestContextHolder
.
currentRequestAttributes
().
getAttribute
(
"fileKey"
,
0
);
String
fileKey
=
(
String
)
RequestContextHolder
.
currentRequestAttributes
().
getAttribute
(
"fileKey"
,
0
);
List
imgUrls
=
Lists
.
newArrayList
(
url
);
List
imgUrls
=
Lists
.
newArrayList
(
url
);
try
{
try
{
imgUrls
.
clear
();
imgUrls
.
clear
();
imgUrls
.
addAll
(
fileUtils
.
getImgCache
(
fileKey
));
imgUrls
.
addAll
(
fileUtils
.
getImgCache
(
fileKey
));
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
imgUrls
=
Lists
.
newArrayList
(
url
);
imgUrls
=
Lists
.
newArrayList
(
url
);
}
}
model
.
addAttribute
(
"imgurls"
,
imgUrls
);
// 不是http开头,浏览器不能直接访问,需下载到本地
model
.
addAttribute
(
"currentUrl"
,
url
);
if
(
url
!=
null
&&
!
url
.
toLowerCase
().
startsWith
(
"http"
))
{
ReturnResponse
<
String
>
response
=
downloadUtils
.
downLoad
(
fileAttribute
,
null
);
if
(
0
!=
response
.
getCode
())
{
model
.
addAttribute
(
"fileType"
,
fileAttribute
.
getSuffix
());
model
.
addAttribute
(
"msg"
,
response
.
getMsg
());
return
"fileNotSupported"
;
}
else
{
String
file
=
fileUtils
.
getRelativePath
(
response
.
getContent
());
model
.
addAttribute
(
"imgurls"
,
Lists
.
newArrayList
(
file
));
model
.
addAttribute
(
"currentUrl"
,
file
);
}
}
else
{
model
.
addAttribute
(
"imgurls"
,
imgUrls
);
model
.
addAttribute
(
"currentUrl"
,
url
);
}
return
"picture"
;
return
"picture"
;
}
}
}
}
jodconverter-web/src/main/resources/web/picture.ftl
View file @
5196536b
...
@@ -24,6 +24,11 @@
...
@@ -24,6 +24,11 @@
<body>
<body>
<ul
id=
"dowebok"
>
<ul
id=
"dowebok"
>
<
#
list
imgurls
as
img
>
<
#
list
imgurls
as
img
>
<
#
if
img
?
contains
("
http:
//")
||
img
?
contains
("
https:
//")
>
<
#
assign
img=
"${img}"
>
<
#
else
>
<
#
assign
img=
"${baseUrl}${img}"
>
</
#
if>
<li><img
id=
"${img}"
url=
"${img}"
src=
"${img}"
width=
"1px"
height=
"1px"
></li>
<li><img
id=
"${img}"
url=
"${img}"
src=
"${img}"
width=
"1px"
height=
"1px"
></li>
</
#
list>
</
#
list>
</ul>
</ul>
...
...
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