Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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