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
374c0647
Commit
374c0647
authored
Jan 09, 2021
by
chenkailing
Committed by
kl
Jan 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
移除 apache-commons-io 包依赖,采用jodd的io工具替代
parent
12c85c60
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
11 deletions
+8
-11
pom.xml
server/pom.xml
+0
-5
SimTextFilePreviewImpl.java
...n/java/cn/keking/service/impl/SimTextFilePreviewImpl.java
+2
-2
DownloadUtils.java
server/src/main/java/cn/keking/utils/DownloadUtils.java
+3
-2
OnlinePreviewController.java
...ava/cn/keking/web/controller/OnlinePreviewController.java
+3
-2
No files found.
server/pom.xml
View file @
374c0647
...
...
@@ -105,11 +105,6 @@
<artifactId>
fr.opensagres.xdocreport.document
</artifactId>
<version>
1.0.5
</version>
</dependency>
<dependency>
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
<version>
2.4
</version>
</dependency>
<!-- 解压(apache) -->
<dependency>
<groupId>
org.apache.commons
</groupId>
...
...
server/src/main/java/cn/keking/service/impl/SimTextFilePreviewImpl.java
View file @
374c0647
...
...
@@ -5,8 +5,8 @@ import cn.keking.model.ReturnResponse;
import
cn.keking.service.FilePreview
;
import
cn.keking.utils.DownloadUtils
;
import
cn.keking.utils.KkFileUtils
;
import
jodd.io.FileUtil
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.io.FileUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.ui.Model
;
...
...
@@ -36,7 +36,7 @@ public class SimTextFilePreviewImpl implements FilePreview {
try
{
File
originFile
=
new
File
(
response
.
getContent
());
String
charset
=
KkFileUtils
.
getFileEncode
(
originFile
);
String
fileData
=
FileUtil
s
.
readFileTo
String
(
originFile
,
charset
);
String
fileData
=
FileUtil
.
read
String
(
originFile
,
charset
);
model
.
addAttribute
(
"textData"
,
Base64
.
encodeBase64String
(
fileData
.
getBytes
()));
}
catch
(
IOException
e
)
{
return
otherFilePreview
.
notSupportedFile
(
model
,
fileAttribute
,
e
.
getLocalizedMessage
());
...
...
server/src/main/java/cn/keking/utils/DownloadUtils.java
View file @
374c0647
...
...
@@ -4,7 +4,8 @@ import cn.keking.config.ConfigConstants;
import
cn.keking.model.FileAttribute
;
import
cn.keking.model.ReturnResponse
;
import
io.mola.galimatias.GalimatiasParseException
;
import
org.apache.commons.io.FileUtils
;
import
jodd.io.FileUtil
;
import
jodd.io.NetUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -39,7 +40,7 @@ public class DownloadUtils {
URL
url
=
WebUtils
.
normalizedURL
(
urlStr
);
if
(
isHttpUrl
(
url
))
{
File
realFile
=
new
File
(
realPath
);
FileUtils
.
copyURLToFile
(
url
,
realFile
);
NetUtil
.
downloadFile
(
url
.
toString
(),
realFile
);
}
else
if
(
isFtpUrl
(
url
))
{
String
ftpUsername
=
WebUtils
.
getUrlParameterReg
(
fileAttribute
.
getUrl
(),
URL_PARAM_FTP_USERNAME
);
String
ftpPassword
=
WebUtils
.
getUrlParameterReg
(
fileAttribute
.
getUrl
(),
URL_PARAM_FTP_PASSWORD
);
...
...
server/src/main/java/cn/keking/web/controller/OnlinePreviewController.java
View file @
374c0647
...
...
@@ -8,9 +8,10 @@ import cn.keking.service.cache.CacheService;
import
cn.keking.service.impl.OtherFilePreviewImpl
;
import
cn.keking.service.FileHandlerService
;
import
cn.keking.utils.WebUtils
;
import
fr.opensagres.xdocreport.core.io.IOUtils
;
import
io.mola.galimatias.GalimatiasParseException
;
import
jodd.io.NetUtil
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.io.IOUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Controller
;
...
...
@@ -103,7 +104,7 @@ public class OnlinePreviewController {
logger
.
info
(
"下载跨域pdf文件url:{}"
,
urlPath
);
try
{
URL
url
=
WebUtils
.
normalizedURL
(
urlPath
);
byte
[]
bytes
=
IOUtils
.
toByteArray
(
url
);
byte
[]
bytes
=
NetUtil
.
downloadBytes
(
url
.
toString
()
);
IOUtils
.
write
(
bytes
,
response
.
getOutputStream
());
}
catch
(
IOException
|
GalimatiasParseException
e
)
{
logger
.
error
(
"下载跨域pdf文件异常,url:{}"
,
urlPath
,
e
);
...
...
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