Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beyond-clouds
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
段启岩
beyond-clouds
Commits
f975c4f6
Commit
f975c4f6
authored
Feb 10, 2020
by
段启岩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文件大小限制
parent
f6017fdb
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
4 deletions
+59
-4
src/main/java/cn/meteor/beyondclouds/common/handler/GlobalExceptionHandler.java
+5
-1
src/main/java/cn/meteor/beyondclouds/modules/resource/enums/FileUploadErrorCode.java
+2
-1
src/main/java/cn/meteor/beyondclouds/modules/resource/enums/UploadType.java
+26
-1
src/main/resources/application-dev.yml
+9
-0
src/main/resources/application-prod.yml
+9
-0
src/main/resources/application.yml
+8
-1
No files found.
src/main/java/cn/meteor/beyondclouds/common/handler/GlobalExceptionHandler.java
View file @
f975c4f6
...
...
@@ -4,10 +4,12 @@ import cn.meteor.beyondclouds.common.enums.ErrorCode;
import
cn.meteor.beyondclouds.config.properties.BeyondCloudsProperties
;
import
cn.meteor.beyondclouds.core.api.Response
;
import
cn.meteor.beyondclouds.core.exception.ServiceException
;
import
cn.meteor.beyondclouds.modules.resource.enums.FileUploadErrorCode
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.HttpRequestMethodNotSupportedException
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
org.springframework.web.multipart.MaxUploadSizeExceededException
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.ByteArrayOutputStream
;
...
...
@@ -36,7 +38,9 @@ public class GlobalExceptionHandler {
return
Response
.
error
(
exception
.
getErrorCode
(),
exception
.
getErrorMsg
());
}
else
if
(
e
instanceof
HttpRequestMethodNotSupportedException
){
return
Response
.
error
(
ErrorCode
.
OPERATION_FAILED
.
code
(),
e
.
getMessage
());
}
else
{
}
else
if
(
e
instanceof
MaxUploadSizeExceededException
)
{
return
Response
.
error
(
FileUploadErrorCode
.
MAXIMUM_UPLOAD_SIZE_EXCEEDED
);
}
{
if
(
debugMode
)
{
ByteArrayOutputStream
byteBuff
=
new
ByteArrayOutputStream
();
e
.
printStackTrace
(
new
PrintStream
(
byteBuff
));
...
...
src/main/java/cn/meteor/beyondclouds/modules/resource/enums/FileUploadErrorCode.java
View file @
f975c4f6
...
...
@@ -8,7 +8,8 @@ import cn.meteor.beyondclouds.core.IErrorCode;
public
enum
FileUploadErrorCode
implements
IErrorCode
{
UPLOAD_FAILURE
(
2001
,
"文件上传失败"
),
UPLOAD_TYPE_ERROR
(
2002
,
"文件上传类型错误"
);
UPLOAD_TYPE_ERROR
(
2002
,
"文件上传类型错误"
),
MAXIMUM_UPLOAD_SIZE_EXCEEDED
(
2003
,
"不能上传超过10MB的文件"
);
private
long
code
;
private
String
msg
;
...
...
src/main/java/cn/meteor/beyondclouds/modules/resource/enums/UploadType.java
View file @
f975c4f6
...
...
@@ -18,7 +18,32 @@ public enum UploadType {
/**
* 上传项目封面
*/
PROJECT_COVER
(
2
,
"project/cover/"
);
PROJECT_COVER
(
2
,
"project/cover/"
),
/**
* 上传动态图片
*/
TRENDS_IMAGES
(
3
,
"trends/images/"
),
/**
* 上传内容图片
*/
BLOG_IMAGES
(
4
,
"blog/images/"
),
/**
* 上传项目内容图片
*/
PROJECT_IMAGES
(
5
,
"project/images/"
),
/**
* 上传问答内容图片
*/
QUESTION_IMAGES
(
6
,
"question/images/"
),
/**
* 上传CMS内容图片
*/
CMS_IMAGES
(
100
,
"cms/images/"
);
private
int
ordinal
;
private
String
basePath
;
...
...
src/main/resources/application-dev.yml
View file @
f975c4f6
...
...
@@ -46,6 +46,15 @@ spring:
key-serializer
:
org.apache.kafka.common.serialization.StringSerializer
value-serializer
:
org.apache.kafka.common.serialization.StringSerializer
servlet
:
multipart
:
max-file-size
:
10MB
max-request-size
:
10MB
server
:
tomcat
:
max-swallow-size
:
100MB
# swagger
swagger
:
enable
:
true
...
...
src/main/resources/application-prod.yml
View file @
f975c4f6
...
...
@@ -46,6 +46,15 @@ spring:
key-serializer
:
org.apache.kafka.common.serialization.StringSerializer
value-serializer
:
org.apache.kafka.common.serialization.StringSerializer
servlet
:
multipart
:
max-file-size
:
10MB
max-request-size
:
10MB
server
:
tomcat
:
max-swallow-size
:
100MB
# swagger
swagger
:
enable
:
true
...
...
src/main/resources/application.yml
View file @
f975c4f6
spring
:
# 数据源
datasource
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
...
...
@@ -45,6 +44,14 @@ spring:
enable-auto-commit
:
true
key-serializer
:
org.apache.kafka.common.serialization.StringSerializer
value-serializer
:
org.apache.kafka.common.serialization.StringSerializer
servlet
:
multipart
:
max-file-size
:
10MB
max-request-size
:
10MB
server
:
tomcat
:
max-swallow-size
:
100MB
# swagger
swagger
:
...
...
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