Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
HOTEL_SERVER
Overview
Overview
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
汪鑫
HOTEL_SERVER
Commits
7cc61755
Commit
7cc61755
authored
Sep 25, 2023
by
汪鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
图片压缩代码修正
parent
27b63f75
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
CommonController.java
...n/java/com/ihooyah/model/controller/CommonController.java
+17
-0
No files found.
hotel-polebuild-parent/polebuild-server-api/src/main/java/com/ihooyah/model/controller/CommonController.java
View file @
7cc61755
...
@@ -77,6 +77,23 @@ public class CommonController extends BaseController {
...
@@ -77,6 +77,23 @@ public class CommonController extends BaseController {
@ApiOperation
(
"图片转base64"
)
@ApiOperation
(
"图片转base64"
)
@PostMapping
(
"imageToBase64"
)
@PostMapping
(
"imageToBase64"
)
public
RespInfo
<
String
>
imageToBase64
(
MultipartFile
file
)
throws
IOException
{
public
RespInfo
<
String
>
imageToBase64
(
MultipartFile
file
)
throws
IOException
{
// if (file.getSize()/1024 > 10){
// File tempFile = new File("temp/"+file.getOriginalFilename().substring(0,file.getOriginalFilename().indexOf("."))+"(1)"+file.getOriginalFilename().indexOf("."));
// FileWriter writer = FileWriter.create(tempFile);
// writer.writeFromStream(file.getInputStream());
// File newFile = new File("temp/" + file.getOriginalFilename());
// ImgUtil.compress(tempFile,newFile,0.5F);
// FileInputStream fileInputStream = null;
// try {
// fileInputStream = new FileInputStream(newFile);
// file = new MockMultipartFile(newFile.getName(),newFile.getName(),
// ContentType.APPLICATION_OCTET_STREAM.toString(),fileInputStream);
// } catch (Exception e) {
// e.printStackTrace();
// }
// FileUtil.del(tempFile);
// FileUtil.del(newFile);
// }
String
baseStr
=
null
;
String
baseStr
=
null
;
BASE64Encoder
encoder
=
new
BASE64Encoder
();
BASE64Encoder
encoder
=
new
BASE64Encoder
();
baseStr
=
encoder
.
encode
(
file
.
getBytes
());
baseStr
=
encoder
.
encode
(
file
.
getBytes
());
...
...
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