记得上下班打卡 | 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
ad534d28
Commit
ad534d28
authored
Dec 31, 2021
by
jiangxiulong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
阿里云上传增加视频截取帧数
parent
641e7db6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
28 deletions
+71
-28
UploadVo.java
...iquidnet/service/kylin/dto/vo/basicServices/UploadVo.java
+2
-0
PlatformOssFiles.java
.../com/liquidnet/service/kylin/entity/PlatformOssFiles.java
+1
-0
db_kylin_structure.sql
.../liquidnet-service-kylin-impl/docu/db_kylin_structure.sql
+0
-21
db_platform_structure.sql
...dnet-service-platform-impl/docu/db_platform_structure.sql
+22
-0
AlOssController.java
...ce/platform/controller/basicServices/AlOssController.java
+46
-7
No files found.
liquidnet-bus-api/liquidnet-service-kylin-api/src/main/java/com/liquidnet/service/kylin/dto/vo/basicServices/UploadVo.java
View file @
ad534d28
...
@@ -25,6 +25,8 @@ public class UploadVo implements Serializable {
...
@@ -25,6 +25,8 @@ public class UploadVo implements Serializable {
private
String
fileName
;
private
String
fileName
;
@ApiModelProperty
(
value
=
"上传后的地址"
)
@ApiModelProperty
(
value
=
"上传后的地址"
)
private
String
ossPath
;
private
String
ossPath
;
@ApiModelProperty
(
value
=
"视频截帧图片文件地址"
)
private
String
videoImg
;
@ApiModelProperty
(
value
=
"文件类型"
)
@ApiModelProperty
(
value
=
"文件类型"
)
private
String
contentType
;
private
String
contentType
;
@ApiModelProperty
(
value
=
"文件大小"
)
@ApiModelProperty
(
value
=
"文件大小"
)
...
...
liquidnet-bus-do/liquidnet-service-kylin-do/src/main/java/com/liquidnet/service/kylin/entity/PlatformOssFiles.java
View file @
ad534d28
...
@@ -27,6 +27,7 @@ public class PlatformOssFiles implements Serializable ,Cloneable {
...
@@ -27,6 +27,7 @@ public class PlatformOssFiles implements Serializable ,Cloneable {
private
String
ossFilesId
;
private
String
ossFilesId
;
private
String
fileName
;
private
String
fileName
;
private
String
ossPath
;
private
String
ossPath
;
private
String
videoImg
;
private
String
contentType
;
private
String
contentType
;
private
Integer
size
;
private
Integer
size
;
private
String
md5str
;
private
String
md5str
;
...
...
liquidnet-bus-service/liquidnet-service-kylin/liquidnet-service-kylin-impl/docu/db_kylin_structure.sql
View file @
ad534d28
...
@@ -969,27 +969,6 @@ CREATE TABLE `kylin_zhengzai_app_versions`
...
@@ -969,27 +969,6 @@ CREATE TABLE `kylin_zhengzai_app_versions`
DEFAULT
CHARSET
utf8mb4
DEFAULT
CHARSET
utf8mb4
COLLATE
utf8mb4_unicode_ci
COMMENT
'正在现场app版本控制'
;
COLLATE
utf8mb4_unicode_ci
COMMENT
'正在现场app版本控制'
;
drop
TABLE
if
exists
`platform_oss_files`
;
create
table
platform_oss_files
(
`mid`
int
(
11
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`oss_files_id`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'oss_files_id'
,
`file_name`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'源文件名称'
,
`content_type`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'文件类型'
,
`size`
int
NOT
NULL
DEFAULT
0
COMMENT
'文件大小'
,
`md5str`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'md5值判断文件是否相同'
,
`oss_path`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'文件地址(阿里oss)'
,
`buck_type`
tinyint
NOT
NULL
DEFAULT
'0'
COMMENT
'buck_type'
,
`uploader_uid`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'上传人id'
,
`uploader_name`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'上传人姓名'
,
`created_at`
timestamp
NULL
DEFAULT
NULL
,
`updated_at`
timestamp
NULL
DEFAULT
NULL
,
KEY
`kylin_oss_files_id_index`
(
`oss_files_id`
),
PRIMARY
KEY
(
`mid`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
utf8mb4
COLLATE
utf8mb4_unicode_ci
COMMENT
'阿里云OSS上传记录'
;
drop
TABLE
if
exists
`admin_upush`
;
drop
TABLE
if
exists
`admin_upush`
;
CREATE
TABLE
`admin_upush`
CREATE
TABLE
`admin_upush`
(
(
...
...
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/docu/db_platform_structure.sql
0 → 100755
View file @
ad534d28
drop
TABLE
if
exists
`platform_oss_files`
;
create
table
platform_oss_files
(
`mid`
int
(
11
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`oss_files_id`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'oss_files_id'
,
`file_name`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'源文件名称'
,
`content_type`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'文件类型'
,
`size`
int
NOT
NULL
DEFAULT
0
COMMENT
'文件大小'
,
`md5str`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'md5值判断文件是否相同'
,
`oss_path`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'文件地址(阿里oss)'
,
`buck_type`
tinyint
NOT
NULL
DEFAULT
'0'
COMMENT
'buck_type'
,
`uploader_uid`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'上传人id'
,
`uploader_name`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'上传人姓名'
,
`created_at`
timestamp
NULL
DEFAULT
NULL
,
`updated_at`
timestamp
NULL
DEFAULT
NULL
,
KEY
`kylin_oss_files_id_index`
(
`oss_files_id`
),
PRIMARY
KEY
(
`mid`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
utf8mb4
COLLATE
utf8mb4_unicode_ci
COMMENT
'阿里云OSS上传记录'
;
alter
table
platform_oss_files
add
video_img
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'视频截帧图片文件地址(阿里oss)'
after
oss_path
;
\ No newline at end of file
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/src/main/java/com/liquidnet/service/platform/controller/basicServices/AlOssController.java
View file @
ad534d28
...
@@ -29,6 +29,8 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -29,6 +29,8 @@ import org.springframework.web.bind.annotation.RestController;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.File
;
import
java.io.File
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.Formatter
;
import
java.util.Formatter
;
import
java.util.List
;
import
java.util.List
;
...
@@ -53,6 +55,8 @@ public class AlOssController {
...
@@ -53,6 +55,8 @@ public class AlOssController {
private
String
accessKeyId
;
private
String
accessKeyId
;
@Value
(
"${liquidnet.al-oss.accessKeySecret}"
)
@Value
(
"${liquidnet.al-oss.accessKeySecret}"
)
private
String
accessKeySecret
;
private
String
accessKeySecret
;
@Value
(
"${liquidnet.al-oss.imgUrl}"
)
private
String
imgUrl
;
@Autowired
@Autowired
private
PlatformOssFilesMapper
platformOssFilesMapper
;
private
PlatformOssFilesMapper
platformOssFilesMapper
;
...
@@ -61,15 +65,17 @@ public class AlOssController {
...
@@ -61,15 +65,17 @@ public class AlOssController {
@ApiOperation
(
"阿里云上传"
)
@ApiOperation
(
"阿里云上传"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
type
=
"form"
,
dataType
=
"File"
,
name
=
"file"
,
value
=
"文件"
,
required
=
true
),
@ApiImplicitParam
(
type
=
"form"
,
dataType
=
"File"
,
name
=
"file"
,
value
=
"文件"
,
required
=
true
),
@ApiImplicitParam
(
type
=
"form"
,
dataType
=
"String"
,
name
=
"pathName"
,
value
=
"归类的文件夹名称 比如banner上传就传 banner 返回的地址就会是bnanner/XXX"
,
defaultValue
=
"
other
"
),
@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
=
"buckType"
,
value
=
"buckType 1正常的任何文件上传 2apk上传"
,
defaultValue
=
"1"
),
@ApiImplicitParam
(
type
=
"form"
,
dataType
=
"Integer"
,
name
=
"resize"
,
value
=
"resize"
,
defaultValue
=
"0"
),
@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
>
upload
(
public
ResponseDto
<
UploadVo
>
upload
(
@RequestParam
MultipartFile
file
,
@RequestParam
MultipartFile
file
,
@RequestParam
(
defaultValue
=
"other"
)
String
pathName
,
@RequestParam
(
defaultValue
=
"other"
)
String
pathName
,
@RequestParam
(
defaultValue
=
"1"
,
required
=
false
)
int
buckType
,
@RequestParam
(
defaultValue
=
"1"
,
required
=
false
)
int
buckType
,
@RequestParam
(
defaultValue
=
"0"
,
required
=
false
)
int
resize
@RequestParam
(
defaultValue
=
"0"
,
required
=
false
)
int
resize
,
@RequestParam
(
defaultValue
=
"0"
,
required
=
false
)
int
isCutFrame
)
{
)
{
File
fileNew
=
FilesUtils
.
multipartFileToFile
(
file
);
File
fileNew
=
FilesUtils
.
multipartFileToFile
(
file
);
if
(
null
==
fileNew
)
{
if
(
null
==
fileNew
)
{
...
@@ -81,7 +87,7 @@ public class AlOssController {
...
@@ -81,7 +87,7 @@ public class AlOssController {
UploadVo
uploadVo
=
new
UploadVo
();
UploadVo
uploadVo
=
new
UploadVo
();
if
(
null
==
ossFile
)
{
if
(
null
==
ossFile
)
{
// 上传
// 上传
ossFile
=
this
.
uploadOssFile
(
file
,
pathName
,
buckType
,
resize
,
fileNew
);
ossFile
=
this
.
uploadOssFile
(
file
,
pathName
,
buckType
,
resize
,
fileNew
,
isCutFrame
);
}
}
BeanUtils
.
copyProperties
(
ossFile
,
uploadVo
);
BeanUtils
.
copyProperties
(
ossFile
,
uploadVo
);
...
@@ -93,6 +99,7 @@ public class AlOssController {
...
@@ -93,6 +99,7 @@ public class AlOssController {
/**
/**
* 获取老的上传文件
* 获取老的上传文件
*
* @param file
* @param file
* @return
* @return
*/
*/
...
@@ -111,6 +118,7 @@ public class AlOssController {
...
@@ -111,6 +118,7 @@ public class AlOssController {
/**
/**
* 上传文件
* 上传文件
*
* @param file
* @param file
* @param pathName
* @param pathName
* @param buckType
* @param buckType
...
@@ -118,9 +126,25 @@ public class AlOssController {
...
@@ -118,9 +126,25 @@ public class AlOssController {
* @param fileNew
* @param fileNew
* @return
* @return
*/
*/
private
PlatformOssFiles
uploadOssFile
(
MultipartFile
file
,
String
pathName
,
int
buckType
,
int
resize
,
File
fileNew
)
{
private
PlatformOssFiles
uploadOssFile
(
MultipartFile
file
,
String
pathName
,
int
buckType
,
int
resize
,
File
fileNew
,
int
isCutFrame
)
{
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
String
filename
=
file
.
getResource
().
getFilename
();
String
filename
=
""
;
String
contentType
=
""
;
int
size
=
0
;
if
(
null
==
file
)
{
filename
=
fileNew
.
getName
();
Path
fileNewPath
=
new
File
(
fileNew
.
getPath
()).
toPath
();
try
{
contentType
=
Files
.
probeContentType
(
fileNewPath
);
}
catch
(
Exception
e
)
{
}
size
=
(
int
)
fileNew
.
length
();
}
else
{
filename
=
file
.
getResource
().
getFilename
();
contentType
=
file
.
getContentType
();
size
=
(
int
)
file
.
getSize
();
}
String
uploadPath
=
FilesUtils
.
getUploadPath
(
pathName
,
filename
);
String
uploadPath
=
FilesUtils
.
getUploadPath
(
pathName
,
filename
);
String
bucketName
=
FilesUtils
.
getBucketName
(
buckType
);
String
bucketName
=
FilesUtils
.
getBucketName
(
buckType
);
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
bucketName
,
uploadPath
,
fileNew
);
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
bucketName
,
uploadPath
,
fileNew
);
...
@@ -130,6 +154,11 @@ public class AlOssController {
...
@@ -130,6 +154,11 @@ public class AlOssController {
this
.
ossFileResize
(
resize
,
uploadPath
,
bucketName
,
ossClient
);
this
.
ossFileResize
(
resize
,
uploadPath
,
bucketName
,
ossClient
);
}
}
PlatformOssFiles
ossFileVideoImg
=
null
;
if
(
isCutFrame
>
0
)
{
// 截取帧数
ossFileVideoImg
=
this
.
ossFileCutFrame
(
uploadPath
,
pathName
,
buckType
);
}
ossClient
.
shutdown
();
ossClient
.
shutdown
();
// 入库
// 入库
...
@@ -137,9 +166,12 @@ public class AlOssController {
...
@@ -137,9 +166,12 @@ public class AlOssController {
String
ossFilesId
=
IDGenerator
.
nextSnowId
();
String
ossFilesId
=
IDGenerator
.
nextSnowId
();
platformOssFilesDate
.
setOssFilesId
(
ossFilesId
);
platformOssFilesDate
.
setOssFilesId
(
ossFilesId
);
platformOssFilesDate
.
setOssPath
(
uploadPath
);
platformOssFilesDate
.
setOssPath
(
uploadPath
);
if
(
null
!=
ossFileVideoImg
)
{
platformOssFilesDate
.
setVideoImg
(
ossFileVideoImg
.
getOssPath
());
}
platformOssFilesDate
.
setFileName
(
filename
);
platformOssFilesDate
.
setFileName
(
filename
);
platformOssFilesDate
.
setContentType
(
file
.
getContentType
()
);
platformOssFilesDate
.
setContentType
(
contentType
);
platformOssFilesDate
.
setSize
(
(
int
)
file
.
getSize
()
);
platformOssFilesDate
.
setSize
(
size
);
String
fileMD5
=
FilesUtils
.
getFileMD5
(
fileNew
);
String
fileMD5
=
FilesUtils
.
getFileMD5
(
fileNew
);
platformOssFilesDate
.
setMd5str
(
fileMD5
);
platformOssFilesDate
.
setMd5str
(
fileMD5
);
platformOssFilesDate
.
setBuckType
(
buckType
);
platformOssFilesDate
.
setBuckType
(
buckType
);
...
@@ -151,6 +183,7 @@ public class AlOssController {
...
@@ -151,6 +183,7 @@ public class AlOssController {
/**
/**
* oss图片裁切
* oss图片裁切
*
* @param resize
* @param resize
* @param uploadPath
* @param uploadPath
* @param bucketName
* @param bucketName
...
@@ -171,6 +204,12 @@ public class AlOssController {
...
@@ -171,6 +204,12 @@ public class AlOssController {
return
processResult
;
return
processResult
;
}
}
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"
;
File
fileNew
=
FilesUtils
.
inputStreamToFile
(
imgUrl
.
concat
(
ossFileUrl
).
concat
(
style
),
System
.
currentTimeMillis
()
+
".jpg"
);
return
this
.
uploadOssFile
(
null
,
pathName
,
buckType
,
0
,
fileNew
,
0
);
}
@PostMapping
(
"/uploadUrl"
)
@PostMapping
(
"/uploadUrl"
)
@ApiOperation
(
"阿里云上传URL"
)
@ApiOperation
(
"阿里云上传URL"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
...
...
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