记得上下班打卡 | 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
90b6b426
Commit
90b6b426
authored
Mar 24, 2022
by
胡佳晨
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bug_upload_pic' into pre
parents
662ee554
f6079026
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
7 deletions
+55
-7
AlOssController.java
...ce/platform/controller/basicServices/AlOssController.java
+55
-7
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 @
90b6b426
...
@@ -101,7 +101,53 @@ public class AlOssController {
...
@@ -101,7 +101,53 @@ public class AlOssController {
try
{
try
{
if
(
null
==
ossFile
||
(
isCutFrame
>
0
&&
ossFile
.
getVideoImg
().
isEmpty
()))
{
//保证上传过的文件也能截帧
if
(
null
==
ossFile
||
(
isCutFrame
>
0
&&
ossFile
.
getVideoImg
().
isEmpty
()))
{
//保证上传过的文件也能截帧
// 上传
// 上传
ossFile
=
this
.
uploadOssFile
(
file
,
pathName
,
buckType
,
resize
,
fileNew
,
isCutFrame
);
ossFile
=
this
.
uploadOssFile
(
file
,
pathName
,
buckType
,
resize
,
fileNew
,
isCutFrame
,
true
);
}
}
finally
{
// 删除临时文件 因为老文件也生成了所以也要删除
FilesUtils
.
deleteTempFile
(
fileNew
);
}
if
(
null
==
ossFile
)
{
return
ResponseDto
.
failure
(
"上传失败,该文件不合规,请勿上传带有联系方式、色情、涉政、广告等敏感文件"
);
}
else
{
BeanUtils
.
copyProperties
(
ossFile
,
uploadVo
);
return
ResponseDto
.
success
(
uploadVo
);
}
}
@PostMapping
(
"/upload/unsm"
)
@ApiOperation
(
"阿里云上传-不鉴黄"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
type
=
"form"
,
dataType
=
"File"
,
name
=
"file"
,
value
=
"文件"
,
required
=
true
),
@ApiImplicitParam
(
type
=
"form"
,
dataType
=
"String"
,
name
=
"pathName"
,
value
=
"归类的文件夹名称 比如banner上传就传 banner 返回的地址就会是bnanner/XXX"
,
defaultValue
=
"test"
),
@ApiImplicitParam
(
type
=
"form"
,
dataType
=
"Integer"
,
name
=
"buckType"
,
value
=
"buckType 1正常的任何文件上传 2apk上传"
,
defaultValue
=
"1"
),
@ApiImplicitParam
(
type
=
"form"
,
dataType
=
"Integer"
,
name
=
"resize"
,
value
=
"resize"
,
defaultValue
=
"0"
),
@ApiImplicitParam
(
type
=
"form"
,
dataType
=
"Integer"
,
name
=
"isCutFrame"
,
value
=
"是否截取帧数 用于视频获取图片 0不需要 1需要"
,
defaultValue
=
"0"
),
})
public
ResponseDto
<
UploadVo
>
uploadUnSm
(
@RequestParam
MultipartFile
file
,
@RequestParam
(
defaultValue
=
"other"
)
String
pathName
,
@RequestParam
(
defaultValue
=
"1"
,
required
=
false
)
int
buckType
,
@RequestParam
(
defaultValue
=
"0"
,
required
=
false
)
int
resize
,
@RequestParam
(
defaultValue
=
"0"
,
required
=
false
)
int
isCutFrame
)
{
if
(
file
.
equals
(
""
)
||
file
.
getSize
()
<=
0
)
{
return
ResponseDto
.
failure
(
"不能上传大小为0的文件"
);
}
File
fileNew
=
FilesUtils
.
multipartFileToFile
(
file
);
if
(
null
==
fileNew
)
{
return
ResponseDto
.
failure
(
"multipartFileToFile Error"
);
}
// 是否上传过 有直接返回
PlatformOssFiles
ossFile
=
this
.
getOldOssFile
(
fileNew
);
UploadVo
uploadVo
=
new
UploadVo
();
try
{
if
(
null
==
ossFile
||
(
isCutFrame
>
0
&&
ossFile
.
getVideoImg
().
isEmpty
()))
{
//保证上传过的文件也能截帧
// 上传
ossFile
=
this
.
uploadOssFile
(
file
,
pathName
,
buckType
,
resize
,
fileNew
,
isCutFrame
,
false
);
}
}
}
finally
{
}
finally
{
// 删除临时文件 因为老文件也生成了所以也要删除
// 删除临时文件 因为老文件也生成了所以也要删除
...
@@ -146,7 +192,7 @@ public class AlOssController {
...
@@ -146,7 +192,7 @@ public class AlOssController {
* @param fileNew
* @param fileNew
* @return
* @return
*/
*/
private
PlatformOssFiles
uploadOssFile
(
MultipartFile
file
,
String
pathName
,
int
buckType
,
int
resize
,
File
fileNew
,
int
isCutFrame
)
{
private
PlatformOssFiles
uploadOssFile
(
MultipartFile
file
,
String
pathName
,
int
buckType
,
int
resize
,
File
fileNew
,
int
isCutFrame
,
Boolean
isShuMei
)
{
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
int
size
=
0
;
int
size
=
0
;
String
filename
,
contentType
,
uploadPath
=
""
;
String
filename
,
contentType
,
uploadPath
=
""
;
...
@@ -167,10 +213,12 @@ public class AlOssController {
...
@@ -167,10 +213,12 @@ public class AlOssController {
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
bucketName
,
uploadPath
,
fileNew
);
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
bucketName
,
uploadPath
,
fileNew
);
ossClient
.
putObject
(
putObjectRequest
);
ossClient
.
putObject
(
putObjectRequest
);
if
(
contentType
.
contains
(
"image"
)
&&
!
contentType
.
equals
(
"image/vnd.adobe.photoshop"
))
{
if
(
isShuMei
)
{
if
(!
shumeiUtil
.
checkImage
(
IDGenerator
.
nextSnowId
(),
imgUrl
.
concat
(
uploadPath
)))
{
if
(
contentType
.
contains
(
"image"
)
&&
!
contentType
.
equals
(
"image/vnd.adobe.photoshop"
))
{
ossClient
.
deleteObject
(
bucketName
,
uploadPath
);
if
(!
shumeiUtil
.
checkImage
(
IDGenerator
.
nextSnowId
(),
imgUrl
.
concat
(
uploadPath
)))
{
return
null
;
ossClient
.
deleteObject
(
bucketName
,
uploadPath
);
return
null
;
}
}
}
}
}
...
@@ -238,7 +286,7 @@ public class AlOssController {
...
@@ -238,7 +286,7 @@ public class AlOssController {
private
PlatformOssFiles
ossFileCutFrame
(
String
ossFileUrl
,
String
pathName
,
int
buckType
)
{
private
PlatformOssFiles
ossFileCutFrame
(
String
ossFileUrl
,
String
pathName
,
int
buckType
)
{
String
style
=
"?x-oss-process=video/snapshot,t_0,f_jpg,w_0,h_0,m_fast,ar_auto"
;
String
style
=
"?x-oss-process=video/snapshot,t_0,f_jpg,w_0,h_0,m_fast,ar_auto"
;
File
fileNew
=
FilesUtils
.
inputStreamToFile
(
imgUrl
.
concat
(
ossFileUrl
).
concat
(
style
),
System
.
currentTimeMillis
()
+
".jpg"
);
File
fileNew
=
FilesUtils
.
inputStreamToFile
(
imgUrl
.
concat
(
ossFileUrl
).
concat
(
style
),
System
.
currentTimeMillis
()
+
".jpg"
);
return
this
.
uploadOssFile
(
null
,
pathName
,
buckType
,
0
,
fileNew
,
0
);
return
this
.
uploadOssFile
(
null
,
pathName
,
buckType
,
0
,
fileNew
,
0
,
false
);
}
}
@PostMapping
(
"/uploadUrl"
)
@PostMapping
(
"/uploadUrl"
)
...
...
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