Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
cfld-region-outline
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
cfld-backend
cfld-region-outline
Commits
a1b1de7a
Commit
a1b1de7a
authored
Jan 04, 2024
by
yaobaizheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
图片压缩
parent
2fa44890
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
2 deletions
+25
-2
SysFileController.java
...lyy/admin/moudle/system/controller/SysFileController.java
+1
-1
UploadService.java
...va/com/lyy/admin/moudle/system/service/UploadService.java
+6
-0
UploadServiceImpl.java
...y/admin/moudle/system/service/impl/UploadServiceImpl.java
+18
-1
No files found.
src/main/java/com/lyy/admin/moudle/system/controller/SysFileController.java
View file @
a1b1de7a
...
@@ -43,7 +43,7 @@ public class SysFileController {
...
@@ -43,7 +43,7 @@ public class SysFileController {
@ApiOperation
(
value
=
"华为OBS图片上传"
,
notes
=
""
)
@ApiOperation
(
value
=
"华为OBS图片上传"
,
notes
=
""
)
public
String
uploadImg
(
MultipartFile
file
,
HttpServletResponse
response
)
throws
Exception
{
public
String
uploadImg
(
MultipartFile
file
,
HttpServletResponse
response
)
throws
Exception
{
response
.
setContentType
(
"application/json;charset=GBK"
);
response
.
setContentType
(
"application/json;charset=GBK"
);
return
lyyConfig
.
getObsPath
()
+
"/"
+
uploadService
.
upload
File
(
file
,
"lyy/img"
);
return
lyyConfig
.
getObsPath
()
+
"/"
+
uploadService
.
upload
Img
(
file
,
"lyy/img"
);
}
}
@PostMapping
(
"/uploadFileLocal"
)
@PostMapping
(
"/uploadFileLocal"
)
...
...
src/main/java/com/lyy/admin/moudle/system/service/UploadService.java
View file @
a1b1de7a
...
@@ -12,6 +12,12 @@ public interface UploadService {
...
@@ -12,6 +12,12 @@ public interface UploadService {
*/
*/
String
uploadFile
(
MultipartFile
files
,
String
rootPath
)
throws
Exception
;
String
uploadFile
(
MultipartFile
files
,
String
rootPath
)
throws
Exception
;
/**
* @Description: 文件图片
*/
String
uploadImg
(
MultipartFile
files
,
String
rootPath
)
throws
Exception
;
/**
/**
* @Description: 本地文件上传
* @Description: 本地文件上传
*/
*/
...
...
src/main/java/com/lyy/admin/moudle/system/service/impl/UploadServiceImpl.java
View file @
a1b1de7a
...
@@ -38,7 +38,7 @@ public class UploadServiceImpl implements UploadService {
...
@@ -38,7 +38,7 @@ public class UploadServiceImpl implements UploadService {
* @return 文件存储路径
* @return 文件存储路径
*/
*/
@Override
@Override
public
String
upload
File
(
MultipartFile
files
,
String
rootPath
)
throws
Exception
{
public
String
upload
Img
(
MultipartFile
files
,
String
rootPath
)
throws
Exception
{
//华为obs
//华为obs
if
(
files
==
null
||
files
.
getSize
()
==
0
){
if
(
files
==
null
||
files
.
getSize
()
==
0
){
throw
new
Exception
(
"请上传文件,文件为空"
);
throw
new
Exception
(
"请上传文件,文件为空"
);
...
@@ -71,6 +71,23 @@ public class UploadServiceImpl implements UploadService {
...
@@ -71,6 +71,23 @@ public class UploadServiceImpl implements UploadService {
return
rootPath
+
filePath
;
return
rootPath
+
filePath
;
}
}
@Override
public
String
uploadFile
(
MultipartFile
files
,
String
rootPath
)
throws
Exception
{
//华为obs
if
(
files
==
null
||
files
.
getSize
()
==
0
){
throw
new
Exception
(
"请上传文件,文件为空"
);
}
String
fileOriginalName
=
files
.
getOriginalFilename
();
String
fileLastType
=
fileOriginalName
.
substring
(
files
.
getOriginalFilename
().
lastIndexOf
(
"."
));
// String date = LocalDateTimeUtils.formatNow("yyyy-MM-dd");
String
date
=
DateUtil
.
format
(
LocalDateTime
.
now
(),
"yyyy-MM-dd"
);
String
newFilename
=
IdUtil
.
simpleUUID
()
+
fileLastType
;
String
filePath
=
"/"
+
date
+
"/"
+
newFilename
;
InputStream
inputStream
=
files
.
getInputStream
();
obsUtils
.
ObsUpload
(
bucketName
,
rootPath
+
filePath
,
inputStream
);
return
rootPath
+
filePath
;
}
@Override
@Override
public
String
uploadFileLocal
(
MultipartFile
files
,
String
rootPath
)
throws
Exception
{
public
String
uploadFileLocal
(
MultipartFile
files
,
String
rootPath
)
throws
Exception
{
//华为obs
//华为obs
...
...
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