-
Notifications
You must be signed in to change notification settings - Fork 0
Main <- Develop #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Main <- Develop #79
Changes from all commits
0d7043a
38ae611
7ca20be
244895c
da0a727
746ce8f
8b7d17a
3f708ca
48a0d56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,15 +4,19 @@ | |||||||||||||||||||||||||||
| import com.example.FixLog.dto.Response; | ||||||||||||||||||||||||||||
| import com.example.FixLog.dto.post.PostResponseDto; | ||||||||||||||||||||||||||||
| import com.example.FixLog.service.PostService; | ||||||||||||||||||||||||||||
| import com.example.FixLog.service.S3Service; | ||||||||||||||||||||||||||||
| import org.springframework.web.bind.annotation.*; | ||||||||||||||||||||||||||||
| import org.springframework.web.multipart.MultipartFile; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| @RestController | ||||||||||||||||||||||||||||
| @RequestMapping("/posts") | ||||||||||||||||||||||||||||
| public class PostController { | ||||||||||||||||||||||||||||
| private final PostService postService; | ||||||||||||||||||||||||||||
| private final S3Service s3Service; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| public PostController(PostService postService){ | ||||||||||||||||||||||||||||
| public PostController(PostService postService, S3Service s3Service){ | ||||||||||||||||||||||||||||
| this.postService = postService; | ||||||||||||||||||||||||||||
| this.s3Service = s3Service; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| @PostMapping | ||||||||||||||||||||||||||||
|
|
@@ -21,6 +25,12 @@ public Response<Object> createPost(@RequestBody PostRequestDto postRequestDto){ | |||||||||||||||||||||||||||
| return Response.success("게시글 작성 성공.", null); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| @PostMapping("/images") | ||||||||||||||||||||||||||||
| public Response<String> uploadImage(@RequestPart("imageFile") MultipartFile imageFile){ | ||||||||||||||||||||||||||||
| String markdownImage = postService.uploadImage(imageFile); | ||||||||||||||||||||||||||||
| return Response.success("이미지 마크다운 형식으로 변환", markdownImage); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
Comment on lines
+28
to
+32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 이미지 업로드 엔드포인트에 입력 검증을 추가해주세요. MultipartFile에 대한 기본적인 검증(null 체크, 파일 크기, 파일 타입 등)을 컨트롤러 레벨에서 수행하는 것이 좋습니다. @PostMapping("/images")
-public Response<String> uploadImage(@RequestPart("imageFile") MultipartFile imageFile){
+public Response<String> uploadImage(@RequestPart("imageFile") MultipartFile imageFile){
+ if (imageFile == null || imageFile.isEmpty()) {
+ throw new CustomException(ErrorCode.IMAGE_UPLOAD_FAILED);
+ }
String markdownImage = postService.uploadImage(imageFile);
return Response.success("이미지 마크다운 형식으로 변환", markdownImage);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| @GetMapping("/{postId}") | ||||||||||||||||||||||||||||
| public Response<Object> viewPost(@PathVariable("postId") Long postId){ | ||||||||||||||||||||||||||||
| PostResponseDto viewPost = postService.viewPost(postId); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
This file was deleted.
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.