Skip to content

Commit 8c57cf8

Browse files
committed
파일 업로드 API 수정: @RequestParam에서 @RequestPart로 변경하고, Swagger 문서화 추가
1 parent 77b56c5 commit 8c57cf8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/main/java/inha/gdgoc/domain/resource/controller/FileUploadController.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package inha.gdgoc.domain.resource.controller;
22

3+
import io.swagger.v3.oas.annotations.Operation;
34
import inha.gdgoc.domain.resource.enums.S3KeyType;
45
import inha.gdgoc.domain.resource.service.S3Service;
56
import inha.gdgoc.global.dto.response.ApiResponse;
67
import lombok.RequiredArgsConstructor;
8+
import org.springframework.http.MediaType;
79
import org.springframework.http.ResponseEntity;
810
import org.springframework.web.bind.annotation.PostMapping;
911
import org.springframework.web.bind.annotation.RequestMapping;
10-
import org.springframework.web.bind.annotation.RequestParam;
12+
import org.springframework.web.bind.annotation.RequestPart;
1113
import org.springframework.web.bind.annotation.RestController;
1214
import org.springframework.web.multipart.MultipartFile;
1315

@@ -20,9 +22,10 @@ public class FileUploadController {
2022

2123
private record UploadResponse(String url) {}
2224

23-
@PostMapping
25+
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
26+
@Operation(summary = "파일 업로드", description = "multipart/form-data로 파일 업로드 후 S3 URL 반환")
2427
public ResponseEntity<ApiResponse<UploadResponse, Void>> upload(
25-
@RequestParam("file") MultipartFile file
28+
@RequestPart("file") MultipartFile file
2629
) throws Exception {
2730
String key = s3Service.upload(0L, S3KeyType.study, file);
2831
String url = s3Service.getS3FileUrl(key);

0 commit comments

Comments
 (0)