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
5ec53c4b
Commit
5ec53c4b
authored
Dec 29, 2020
by
kl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
指定Base64转码采用Apache Commons-code中的实现,修复base64部分jdk版本下出现的异常
parent
ee7f7f50
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
7 deletions
+6
-7
SimTextFilePreviewImpl.java
...n/java/cn/keking/service/impl/SimTextFilePreviewImpl.java
+2
-3
OnlinePreviewController.java
...ava/cn/keking/web/controller/OnlinePreviewController.java
+4
-4
No files found.
server/src/main/java/cn/keking/service/impl/SimTextFilePreviewImpl.java
View file @
5ec53c4b
...
...
@@ -5,14 +5,13 @@ import cn.keking.model.ReturnResponse;
import
cn.keking.service.FilePreview
;
import
cn.keking.utils.DownloadUtils
;
import
cn.keking.utils.KkFileUtils
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.io.FileUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.ui.Model
;
import
org.springframework.util.Base64Utils
;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.charset.StandardCharsets
;
/**
* Created by kl on 2018/1/17.
...
...
@@ -38,7 +37,7 @@ public class SimTextFilePreviewImpl implements FilePreview {
File
originFile
=
new
File
(
response
.
getContent
());
String
charset
=
KkFileUtils
.
getFileEncode
(
originFile
);
String
fileData
=
FileUtils
.
readFileToString
(
originFile
,
charset
);
model
.
addAttribute
(
"textData"
,
Base64
Utils
.
encodeToString
(
fileData
.
getBytes
(
StandardCharsets
.
UTF_8
)));
model
.
addAttribute
(
"textData"
,
Base64
.
encodeBase64String
(
fileData
.
getBytes
(
)));
}
catch
(
IOException
e
)
{
return
otherFilePreview
.
notSupportedFile
(
model
,
fileAttribute
,
e
.
getLocalizedMessage
());
}
...
...
server/src/main/java/cn/keking/web/controller/OnlinePreviewController.java
View file @
5ec53c4b
...
...
@@ -9,12 +9,12 @@ import cn.keking.service.impl.OtherFilePreviewImpl;
import
cn.keking.service.FileHandlerService
;
import
cn.keking.utils.WebUtils
;
import
io.mola.galimatias.GalimatiasParseException
;
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
;
import
org.springframework.ui.Model
;
import
org.springframework.util.Base64Utils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
...
...
@@ -54,7 +54,7 @@ public class OnlinePreviewController {
public
String
onlinePreview
(
String
url
,
Model
model
,
HttpServletRequest
req
)
{
String
fileUrl
;
try
{
fileUrl
=
new
String
(
Base64
Utils
.
decodeFromString
(
url
));
fileUrl
=
new
String
(
Base64
.
decodeBase64
(
url
));
}
catch
(
Exception
ex
)
{
String
errorMsg
=
String
.
format
(
BASE64_DECODE_ERROR_MSG
,
"url"
);
return
otherFilePreview
.
notSupportedFile
(
model
,
errorMsg
);
...
...
@@ -70,7 +70,7 @@ public class OnlinePreviewController {
public
String
picturesPreview
(
String
urls
,
Model
model
,
HttpServletRequest
req
)
throws
UnsupportedEncodingException
{
String
fileUrls
;
try
{
fileUrls
=
new
String
(
Base64
Utils
.
decodeFromString
(
urls
));
fileUrls
=
new
String
(
Base64
.
decodeBase64
(
urls
));
}
catch
(
Exception
ex
)
{
String
errorMsg
=
String
.
format
(
BASE64_DECODE_ERROR_MSG
,
"urls"
);
return
otherFilePreview
.
notSupportedFile
(
model
,
errorMsg
);
...
...
@@ -83,7 +83,7 @@ public class OnlinePreviewController {
String
currentUrl
=
req
.
getParameter
(
"currentUrl"
);
if
(
StringUtils
.
hasText
(
currentUrl
))
{
String
decodedCurrentUrl
=
new
String
(
Base64
Utils
.
decodeFromString
(
currentUrl
));
String
decodedCurrentUrl
=
new
String
(
Base64
.
decodeBase64
(
currentUrl
));
model
.
addAttribute
(
"currentUrl"
,
decodedCurrentUrl
);
}
else
{
model
.
addAttribute
(
"currentUrl"
,
imgUrls
.
get
(
0
));
...
...
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