记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
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
董敬伟
liquidnet-bus-v1
Commits
c9ca34d9
Commit
c9ca34d9
authored
Jul 15, 2021
by
jiangxiulong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口格式更改
parent
85d8cace
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
48 deletions
+43
-48
AlOssController.java
...ce/platform/controller/basicServices/AlOssController.java
+43
-48
No files found.
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/src/main/java/com/liquidnet/service/platform/controller/basicServices/AlOssController.java
View file @
c9ca34d9
...
...
@@ -83,58 +83,53 @@ public class AlOssController {
// file md5
String
fileMD5
=
FilesUtils
.
getFileMD5
(
fileNew
);
PlatformOssFiles
platformOssFiles
=
platformOssFilesMapper
.
selectOne
(
Wrappers
.
lambdaQuery
(
PlatformOssFiles
.
class
).
eq
(
PlatformOssFiles:
:
getMd5str
,
fileMD5
));
if
(
null
!=
platformOssFiles
)
{
UploadVo
uploadVo
=
new
UploadVo
();
uploadVo
.
setOssPath
(
platformOssFiles
.
getOssPath
());
uploadVo
.
setSize
(
platformOssFiles
.
getSize
());
uploadVo
.
setContentType
(
platformOssFiles
.
getContentType
());
return
ResponseDto
.
success
(
uploadVo
);
}
String
filename
=
file
.
getResource
().
getFilename
();
// time.jpeg
//这里文件名用了uuid 防止重复,可以根据自己的需要来写
String
uploadName
=
UUID
.
randomUUID
()
+
filename
.
substring
(
filename
.
lastIndexOf
(
"."
));
// 078a77e0-cf80-481b-824c-5935247cff15.jpeg
uploadName
=
uploadName
.
replace
(
"-"
,
""
);
// 078a77e0cf80481b824c5935247cff15.jpeg
String
uploadpath
=
pathName
+
"/"
+
DateUtil
.
format
(
LocalDateTime
.
now
(),
DateUtil
.
Formatter
.
yyyy_MM_dd2
)
+
"/"
+
uploadName
;
String
buckName
=
"img-zhengzai-tv"
;
if
(
2
==
buckType
)
{
buckName
=
"app-zhengzai-tv"
;
}
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
buckName
,
uploadpath
,
fileNew
);
ossClient
.
putObject
(
putObjectRequest
);
if
(
resize
>
0
)
{
// 将图片缩放
StringBuilder
sbStyle
=
new
StringBuilder
();
Formatter
styleFormatter
=
new
Formatter
(
sbStyle
);
String
styleType
=
"image/resize,w_"
+
resize
;
// String styleType = "image/resize,m_fixed,w_100,h_100";
styleFormatter
.
format
(
"%s|sys/saveas,o_%s,b_%s"
,
styleType
,
BinaryUtil
.
toBase64String
(
uploadpath
.
getBytes
()),
BinaryUtil
.
toBase64String
(
buckName
.
getBytes
()));
ProcessObjectRequest
request
=
new
ProcessObjectRequest
(
buckName
,
uploadpath
,
sbStyle
.
toString
());
GenericResult
processResult
=
ossClient
.
processObject
(
request
);
}
UploadVo
uploadVo
=
new
UploadVo
();
if
(
null
==
platformOssFiles
)
{
String
filename
=
file
.
getResource
().
getFilename
();
// time.jpeg
//这里文件名用了uuid 防止重复,可以根据自己的需要来写
String
uploadName
=
UUID
.
randomUUID
()
+
filename
.
substring
(
filename
.
lastIndexOf
(
"."
));
// 078a77e0-cf80-481b-824c-5935247cff15.jpeg
uploadName
=
uploadName
.
replace
(
"-"
,
""
);
// 078a77e0cf80481b824c5935247cff15.jpeg
String
uploadpath
=
pathName
+
"/"
+
DateUtil
.
format
(
LocalDateTime
.
now
(),
DateUtil
.
Formatter
.
yyyy_MM_dd2
)
+
"/"
+
uploadName
;
String
buckName
=
"img-zhengzai-tv"
;
if
(
2
==
buckType
)
{
buckName
=
"app-zhengzai-tv"
;
}
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
buckName
,
uploadpath
,
fileNew
);
ossClient
.
putObject
(
putObjectRequest
);
if
(
resize
>
0
)
{
// 将图片缩放
StringBuilder
sbStyle
=
new
StringBuilder
();
Formatter
styleFormatter
=
new
Formatter
(
sbStyle
);
String
styleType
=
"image/resize,w_"
+
resize
;
// String styleType = "image/resize,m_fixed,w_100,h_100";
styleFormatter
.
format
(
"%s|sys/saveas,o_%s,b_%s"
,
styleType
,
BinaryUtil
.
toBase64String
(
uploadpath
.
getBytes
()),
BinaryUtil
.
toBase64String
(
buckName
.
getBytes
()));
ProcessObjectRequest
request
=
new
ProcessObjectRequest
(
buckName
,
uploadpath
,
sbStyle
.
toString
());
GenericResult
processResult
=
ossClient
.
processObject
(
request
);
}
ossClient
.
shutdown
();
FilesUtils
.
delteTempFile
(
fileNew
);
// 删除临时文件
ossClient
.
shutdown
();
FilesUtils
.
delteTempFile
(
fileNew
);
// 删除临时文件
// 入库
PlatformOssFiles
platformOssFilesDate
=
new
PlatformOssFiles
();
String
ossFilesId
=
IDGenerator
.
nextSnowId
();
platformOssFilesDate
.
setOssFilesId
(
ossFilesId
);
platformOssFilesDate
.
setOssPath
(
uploadpath
);
platformOssFilesDate
.
setFileName
(
filename
);
platformOssFilesDate
.
setContentType
(
file
.
getContentType
());
platformOssFilesDate
.
setSize
((
int
)
file
.
getSize
());
platformOssFilesDate
.
setMd5str
(
fileMD5
);
platformOssFilesDate
.
setBuckType
(
buckType
);
platformOssFilesDate
.
setCreatedAt
(
DateUtil
.
getNowTime
());
platformOssFilesMapper
.
insert
(
platformOssFilesDate
);
// 入库
PlatformOssFiles
platformOssFilesDate
=
new
PlatformOssFiles
();
String
ossFilesId
=
IDGenerator
.
nextSnowId
();
platformOssFilesDate
.
setOssFilesId
(
ossFilesId
);
platformOssFilesDate
.
setOssPath
(
uploadpath
);
platformOssFilesDate
.
setFileName
(
filename
);
platformOssFilesDate
.
setContentType
(
file
.
getContentType
());
platformOssFilesDate
.
setSize
((
int
)
file
.
getSize
());
platformOssFilesDate
.
setMd5str
(
fileMD5
);
platformOssFilesDate
.
setBuckType
(
buckType
);
platformOssFilesDate
.
setCreatedAt
(
DateUtil
.
getNowTime
());
platformOssFilesMapper
.
insert
(
platformOssFilesDate
);
// 返回值
UploadVo
uploadVo
=
new
UploadVo
();
BeanUtils
.
copyProperties
(
platformOssFilesDate
,
uploadVo
);
BeanUtils
.
copyProperties
(
platformOssFilesDate
,
uploadVo
);
}
else
{
BeanUtils
.
copyProperties
(
platformOssFiles
,
uploadVo
);
}
return
ResponseDto
.
success
(
uploadVo
);
}
...
...
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