Skip to content

Commit 5b41660

Browse files
authored
GETP-310 feat: 파일 업로드 최대 용량 5MB로 변경 (#179)
1 parent 543e636 commit 5b41660

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package es.princip.getp.api.handler;
2+
3+
import es.princip.getp.api.support.dto.ApiErrorResponse;
4+
import es.princip.getp.api.support.dto.ApiErrorResponse.ApiErrorResult;
5+
import es.princip.getp.domain.support.ErrorDescription;
6+
import lombok.extern.slf4j.Slf4j;
7+
import org.springframework.core.annotation.Order;
8+
import org.springframework.http.HttpStatus;
9+
import org.springframework.http.ResponseEntity;
10+
import org.springframework.web.bind.annotation.ExceptionHandler;
11+
import org.springframework.web.bind.annotation.RestControllerAdvice;
12+
import org.springframework.web.multipart.MaxUploadSizeExceededException;
13+
14+
@Slf4j
15+
@Order(1)
16+
@RestControllerAdvice
17+
public class MaxUploadSizeExceededExceptionHandler {
18+
19+
@ExceptionHandler(MaxUploadSizeExceededException.class)
20+
public ResponseEntity<ApiErrorResult> handle(final MaxUploadSizeExceededException exception) {
21+
log.debug(exception.getMessage(), exception);
22+
final ErrorDescription description = ErrorDescription.of(
23+
"MAX_UPLOAD_SIZE_EXCEEDED",
24+
"최대 허용 파일 크기를 초과했습니다. "
25+
);
26+
return ApiErrorResponse.error(HttpStatus.PAYLOAD_TOO_LARGE, description);
27+
}
28+
}

src/main/java/es/princip/getp/application/storage/FileLog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static FileLog of(final MemberId memberId, final MultipartFile file) {
4646
}
4747

4848
public Path getPath() {
49-
return Paths.get(String.valueOf(memberId))
49+
return Paths.get(String.valueOf(memberId.getValue()))
5050
.resolve(FILE_PREFIX)
5151
.resolve(String.valueOf(id))
5252
.resolve(filename);

src/main/resources/application-dev.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ server:
44
context-path: ${BASE_PATH}
55

66
spring:
7+
servlet:
8+
multipart:
9+
max-file-size: 5MB
10+
711
storage:
812
local:
913
path: ${STORAGE_PATH}

src/main/resources/application-local.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ server:
44
context-path: ${BASE_PATH}
55

66
spring:
7+
servlet:
8+
multipart:
9+
max-file-size: 5MB
10+
711
storage:
812
local:
913
path: ${STORAGE_PATH}

0 commit comments

Comments
 (0)