Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
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
YZG
yzg-util
Commits
7b6b23da
Commit
7b6b23da
authored
Nov 12, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
参数处理
parent
7ac79019
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
8 deletions
+41
-8
YzgFileConfig.java
...c/main/java/com/yanzuoguang/cloud/file/YzgFileConfig.java
+18
-6
YzgFileServiceImpl.java
...n/java/com/yanzuoguang/cloud/file/YzgFileServiceImpl.java
+23
-2
No files found.
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/file/YzgFileConfig.java
View file @
7b6b23da
...
@@ -41,6 +41,18 @@ public class YzgFileConfig {
...
@@ -41,6 +41,18 @@ public class YzgFileConfig {
return
displayUrl
;
return
displayUrl
;
}
}
/**
* 初始化视频
*
* @param serverFile
* @return
*/
public
YzgFileBaseVo
init
(
String
serverFile
)
{
YzgFileBaseVo
item
=
new
YzgFileBaseVo
();
init
(
item
,
serverFile
);
return
item
;
}
/**
/**
* 初始化文件对象
* 初始化文件对象
*
*
...
@@ -53,16 +65,16 @@ public class YzgFileConfig {
...
@@ -53,16 +65,16 @@ public class YzgFileConfig {
item
.
setServer
(
fromUrl
);
item
.
setServer
(
fromUrl
);
// 对外显示全路径
// 对外显示全路径
item
.
setDisplay
(
getUrl
(
this
.
getDisplayUrl
(),
fromUrl
));
item
.
setDisplay
(
getUrl
(
this
.
getDisplayUrl
(),
fromUrl
));
// 文件全路径
// 文件全路径
String
serverFullPath
=
getUrl
(
this
.
getServerUrl
(),
fromUrl
);
String
serverFullPath
=
getUrl
(
this
.
getServerUrl
(),
fromUrl
);
// 获取文件大小
// 获取文件大小
File
file
=
new
File
(
serverFullPath
);
File
file
=
new
File
(
serverFullPath
);
item
.
setSize
(
file
.
length
());
if
(
file
.
exists
())
{
// 获取mime
item
.
setSize
(
file
.
length
());
item
.
setMime
(
FileHelper
.
getMimeType
(
serverFullPath
));
// 获取mime
item
.
setType
(
FileHelper
.
getMediaTypeByMime
(
item
.
getMime
()));
item
.
setMime
(
FileHelper
.
getMimeType
(
serverFullPath
));
item
.
setType
(
FileHelper
.
getMediaTypeByMime
(
item
.
getMime
()));
}
}
}
/**
/**
...
...
yzg-util-file/src/main/java/com/yanzuoguang/cloud/file/YzgFileServiceImpl.java
View file @
7b6b23da
...
@@ -257,7 +257,29 @@ public class YzgFileServiceImpl implements YzgFileService {
...
@@ -257,7 +257,29 @@ public class YzgFileServiceImpl implements YzgFileService {
*/
*/
@Override
@Override
public
void
convertVideoFirst
(
YzgFileConvertVideoFirstReqVo
req
)
{
public
void
convertVideoFirst
(
YzgFileConvertVideoFirstReqVo
req
)
{
checkFolder
(
req
.
getFrom
());
checkFolder
(
req
.
getTo
());
String
fullFrom
=
fileConfig
.
getServerFullPath
(
req
.
getFrom
());
YzgFileBaseVo
fromInfo
=
fileConfig
.
init
(
fullFrom
);
if
(
StringHelper
.
isEmpty
(
fromInfo
.
getMime
()))
{
throw
new
CodeException
(
"来源文件不存在"
);
}
if
(
fromInfo
.
getType
()
!=
FileHelper
.
FILE_TYPE_VIDEO
)
{
throw
new
CodeException
(
"来源文件不为视频"
);
}
try
{
String
fullTo
=
fileConfig
.
getServerFullPath
(
req
.
getTo
());
File
fileTo
=
new
File
(
fullTo
);
if
(
fileTo
.
exists
())
{
fileTo
.
delete
();
}
// 获取第一帧做为缩略图
MediaHelper
.
getVideoFirstImage
(
fullFrom
,
fullTo
);
}
catch
(
CodeException
e
)
{
throw
new
CodeException
(
"获取视频缩略图失败"
,
e
);
}
}
}
/**
/**
...
@@ -304,8 +326,7 @@ public class YzgFileServiceImpl implements YzgFileService {
...
@@ -304,8 +326,7 @@ public class YzgFileServiceImpl implements YzgFileService {
// 来源文件路径
// 来源文件路径
String
from
=
fileConfig
.
getServerFullPath
(
req
.
getFrom
());
String
from
=
fileConfig
.
getServerFullPath
(
req
.
getFrom
());
YzgFileBaseVo
fromInfo
=
new
YzgFileBaseVo
();
YzgFileBaseVo
fromInfo
=
fileConfig
.
init
(
from
);
fileConfig
.
init
(
fromInfo
,
from
);
if
(
fromInfo
.
getType
()
!=
type
)
{
if
(
fromInfo
.
getType
()
!=
type
)
{
throw
new
CodeException
(
"请传入"
+
tag
+
"文件"
);
throw
new
CodeException
(
"请传入"
+
tag
+
"文件"
);
}
}
...
...
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