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
41a72798
Commit
41a72798
authored
Sep 16, 2019
by
陈精华
Committed by
kl
Sep 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化:去除可能导致文件不更新的缓存
parent
03cc1850
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
20 deletions
+12
-20
OfficeFilePreviewImpl.java
...in/java/cn/keking/service/impl/OfficeFilePreviewImpl.java
+6
-12
PdfFilePreviewImpl.java
.../main/java/cn/keking/service/impl/PdfFilePreviewImpl.java
+6
-8
No files found.
jodconverter-web/src/main/java/cn/keking/service/impl/OfficeFilePreviewImpl.java
View file @
41a72798
...
@@ -54,21 +54,15 @@ public class OfficeFilePreviewImpl implements FilePreview {
...
@@ -54,21 +54,15 @@ public class OfficeFilePreviewImpl implements FilePreview {
// 判断之前是否已转换过,如果转换过,直接返回,否则执行转换
// 判断之前是否已转换过,如果转换过,直接返回,否则执行转换
if
(!
fileUtils
.
listConvertedFiles
().
containsKey
(
pdfName
)
||
!
ConfigConstants
.
isCacheEnabled
())
{
if
(!
fileUtils
.
listConvertedFiles
().
containsKey
(
pdfName
)
||
!
ConfigConstants
.
isCacheEnabled
())
{
String
filePath
=
fileDir
+
fileName
;
String
filePath
=
fileDir
+
fileName
;
if
(!
new
File
(
filePath
).
exists
())
{
ReturnResponse
<
String
>
response
=
downloadUtils
.
downLoad
(
fileAttribute
,
null
);
ReturnResponse
<
String
>
response
=
downloadUtils
.
downLoad
(
fileAttribute
,
null
);
if
(
0
!=
response
.
getCode
())
{
if
(
0
!=
response
.
getCode
())
{
model
.
addAttribute
(
"fileType"
,
suffix
);
model
.
addAttribute
(
"fileType"
,
suffix
);
model
.
addAttribute
(
"msg"
,
response
.
getMsg
());
model
.
addAttribute
(
"msg"
,
response
.
getMsg
());
return
"fileNotSupported"
;
return
"fileNotSupported"
;
}
filePath
=
response
.
getContent
();
}
}
filePath
=
response
.
getContent
();
if
(
StringUtils
.
hasText
(
outFilePath
))
{
if
(
StringUtils
.
hasText
(
outFilePath
))
{
officeToPdf
.
openOfficeToPDF
(
filePath
,
outFilePath
);
officeToPdf
.
openOfficeToPDF
(
filePath
,
outFilePath
);
File
f
=
new
File
(
filePath
);
if
(
f
.
exists
())
{
f
.
delete
();
}
if
(
isHtml
)
{
if
(
isHtml
)
{
// 对转换后的文件进行操作(改变编码方式)
// 对转换后的文件进行操作(改变编码方式)
fileUtils
.
doActionConvertedFile
(
outFilePath
);
fileUtils
.
doActionConvertedFile
(
outFilePath
);
...
...
jodconverter-web/src/main/java/cn/keking/service/impl/PdfFilePreviewImpl.java
View file @
41a72798
...
@@ -44,15 +44,13 @@ public class PdfFilePreviewImpl implements FilePreview{
...
@@ -44,15 +44,13 @@ public class PdfFilePreviewImpl implements FilePreview{
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
))
{
//当文件不存在时,就去下载
//当文件不存在时,就去下载
if
(!
new
File
(
outFilePath
).
exists
())
{
ReturnResponse
<
String
>
response
=
downloadUtils
.
downLoad
(
fileAttribute
,
fileName
);
ReturnResponse
<
String
>
response
=
downloadUtils
.
downLoad
(
fileAttribute
,
fileName
);
if
(
0
!=
response
.
getCode
())
{
if
(
0
!=
response
.
getCode
())
{
model
.
addAttribute
(
"fileType"
,
suffix
);
model
.
addAttribute
(
"fileType"
,
suffix
);
model
.
addAttribute
(
"msg"
,
response
.
getMsg
());
model
.
addAttribute
(
"msg"
,
response
.
getMsg
());
return
"fileNotSupported"
;
return
"fileNotSupported"
;
}
outFilePath
=
response
.
getContent
();
}
}
outFilePath
=
response
.
getContent
();
List
<
String
>
imageUrls
=
pdfUtils
.
pdf2jpg
(
outFilePath
,
pdfName
,
originUrl
);
List
<
String
>
imageUrls
=
pdfUtils
.
pdf2jpg
(
outFilePath
,
pdfName
,
originUrl
);
if
(
imageUrls
==
null
||
imageUrls
.
size
()
<
1
)
{
if
(
imageUrls
==
null
||
imageUrls
.
size
()
<
1
)
{
model
.
addAttribute
(
"msg"
,
"pdf转图片异常,请联系管理员"
);
model
.
addAttribute
(
"msg"
,
"pdf转图片异常,请联系管理员"
);
...
...
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