Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sts网站
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
liyang
sts网站
Commits
dd384e4a
Commit
dd384e4a
authored
May 11, 2021
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传媒体类型添加视频格式
parent
bdde195e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
2 deletions
+24
-2
InvalidExtensionException.java
...uoyi/common/exception/file/InvalidExtensionException.java
+10
-0
FileUploadUtils.java
...ain/java/com/ruoyi/common/utils/file/FileUploadUtils.java
+10
-2
MimeTypeUtils.java
.../main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java
+4
-0
No files found.
ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java
View file @
dd384e4a
...
...
@@ -68,4 +68,14 @@ public class InvalidExtensionException extends FileUploadException
super
(
allowedExtension
,
extension
,
filename
);
}
}
public
static
class
InvalidVideoExtensionException
extends
InvalidExtensionException
{
private
static
final
long
serialVersionUID
=
1L
;
public
InvalidVideoExtensionException
(
String
[]
allowedExtension
,
String
extension
,
String
filename
)
{
super
(
allowedExtension
,
extension
,
filename
);
}
}
}
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java
View file @
dd384e4a
...
...
@@ -130,8 +130,11 @@ public class FileUploadUtils
private
static
final
File
getAbsoluteFile
(
String
uploadDir
,
String
fileName
)
throws
IOException
{
File
desc
=
new
File
(
uploadDir
+
File
.
separator
+
fileName
);
if
(!
desc
.
exists
())
{
if
(!
desc
.
getParentFile
().
exists
())
{
if
(!
desc
.
exists
())
{
if
(!
desc
.
getParentFile
().
exists
())
{
desc
.
getParentFile
().
mkdirs
();
}
}
...
...
@@ -182,6 +185,11 @@ public class FileUploadUtils
throw
new
InvalidExtensionException
.
InvalidMediaExtensionException
(
allowedExtension
,
extension
,
fileName
);
}
else
if
(
allowedExtension
==
MimeTypeUtils
.
VIDEO_EXTENSION
)
{
throw
new
InvalidExtensionException
.
InvalidVideoExtensionException
(
allowedExtension
,
extension
,
fileName
);
}
else
{
throw
new
InvalidExtensionException
(
allowedExtension
,
extension
,
fileName
);
...
...
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java
View file @
dd384e4a
...
...
@@ -24,6 +24,8 @@ public class MimeTypeUtils
public
static
final
String
[]
MEDIA_EXTENSION
=
{
"swf"
,
"flv"
,
"mp3"
,
"wav"
,
"wma"
,
"wmv"
,
"mid"
,
"avi"
,
"mpg"
,
"asf"
,
"rm"
,
"rmvb"
};
public
static
final
String
[]
VIDEO_EXTENSION
=
{
"mp4"
,
"avi"
,
"rmvb"
};
public
static
final
String
[]
DEFAULT_ALLOWED_EXTENSION
=
{
// 图片
"bmp"
,
"gif"
,
"jpg"
,
"jpeg"
,
"png"
,
...
...
@@ -31,6 +33,8 @@ public class MimeTypeUtils
"doc"
,
"docx"
,
"xls"
,
"xlsx"
,
"ppt"
,
"pptx"
,
"html"
,
"htm"
,
"txt"
,
// 压缩文件
"rar"
,
"zip"
,
"gz"
,
"bz2"
,
// 视频格式
"mp4"
,
"avi"
,
"rmvb"
,
// pdf
"pdf"
};
...
...
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