Skip to content

Commit

Permalink
GETP-310 feat: 파일 업로드 최대 용량 5MB로 변경 (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
scv1702 authored Nov 3, 2024
1 parent 543e636 commit 5b41660
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package es.princip.getp.api.handler;

import es.princip.getp.api.support.dto.ApiErrorResponse;
import es.princip.getp.api.support.dto.ApiErrorResponse.ApiErrorResult;
import es.princip.getp.domain.support.ErrorDescription;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;

@Slf4j
@Order(1)
@RestControllerAdvice
public class MaxUploadSizeExceededExceptionHandler {

@ExceptionHandler(MaxUploadSizeExceededException.class)
public ResponseEntity<ApiErrorResult> handle(final MaxUploadSizeExceededException exception) {
log.debug(exception.getMessage(), exception);
final ErrorDescription description = ErrorDescription.of(
"MAX_UPLOAD_SIZE_EXCEEDED",
"최대 허용 파일 크기를 초과했습니다. "
);
return ApiErrorResponse.error(HttpStatus.PAYLOAD_TOO_LARGE, description);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static FileLog of(final MemberId memberId, final MultipartFile file) {
}

public Path getPath() {
return Paths.get(String.valueOf(memberId))
return Paths.get(String.valueOf(memberId.getValue()))
.resolve(FILE_PREFIX)
.resolve(String.valueOf(id))
.resolve(filename);
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ server:
context-path: ${BASE_PATH}

spring:
servlet:
multipart:
max-file-size: 5MB

storage:
local:
path: ${STORAGE_PATH}
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ server:
context-path: ${BASE_PATH}

spring:
servlet:
multipart:
max-file-size: 5MB

storage:
local:
path: ${STORAGE_PATH}
Expand Down

0 comments on commit 5b41660

Please sign in to comment.