|
1 | 1 | package cmf.commitField.domain.chat.chatRoom.controller;
|
2 | 2 |
|
3 |
| -import cmf.commitField.domain.File.service.FileService; |
4 | 3 | import cmf.commitField.domain.chat.chatRoom.controller.request.ChatRoomRequest;
|
5 | 4 | import cmf.commitField.domain.chat.chatRoom.controller.request.ChatRoomUpdateRequest;
|
6 | 5 | import cmf.commitField.domain.chat.chatRoom.dto.ChatRoomDto;
|
7 | 6 | import cmf.commitField.domain.chat.chatRoom.dto.ChatRoomUserDto;
|
8 | 7 | import cmf.commitField.domain.chat.chatRoom.service.ChatRoomService;
|
9 | 8 | import cmf.commitField.domain.user.entity.CustomOAuth2User;
|
| 9 | +import cmf.commitField.global.aws.s3.S3Service; |
10 | 10 | import cmf.commitField.global.error.ErrorCode;
|
11 | 11 | import cmf.commitField.global.globalDto.GlobalResponse;
|
12 | 12 | import cmf.commitField.global.security.LoginCheck;
|
|
28 | 28 | @RequestMapping("/chat")
|
29 | 29 | public class ChatRoomController {
|
30 | 30 | private final ChatRoomService chatRoomService;
|
31 |
| - private final FileService fileService; |
| 31 | + private final S3Service s3Service; // S3 ํ์ผ ์ ์ฅ์ ์ํ ์๋น์ค |
32 | 32 |
|
33 | 33 | // ์ฑํ
๋ฐฉ ์์ฑ (ํ์ผ ์
๋ก๋ ํฌํจ)
|
34 | 34 | @PostMapping(value = "/room", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
35 | 35 | public GlobalResponse<Object> createRoom(
|
36 | 36 | @ModelAttribute @Valid ChatRoomRequest chatRoomRequest) throws IOException {
|
37 | 37 |
|
38 |
| - |
39 | 38 | // ์ธ์ฆ ํ์ธ
|
40 | 39 | Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
41 | 40 |
|
42 | 41 | if (authentication instanceof OAuth2AuthenticationToken) {
|
43 | 42 | CustomOAuth2User principal = (CustomOAuth2User) authentication.getPrincipal();
|
44 |
| - Long userId = principal.getId(); // getId()๋ฅผ ํตํด userId๋ฅผ ์ถ์ถ |
| 43 | + Long userId = principal.getId(); // getId()๋ฅผ ํตํด userId ์ถ์ถ |
45 | 44 |
|
46 | 45 | // ํ์ผ ์
๋ก๋ ์ฒ๋ฆฌ
|
47 | 46 | String imageUrl = null;
|
48 | 47 | if (chatRoomRequest.getFile() != null && !chatRoomRequest.getFile().isEmpty()) {
|
49 |
| - imageUrl = fileService.saveFile(chatRoomRequest.getFile()); // ํ์ผ ์ ์ฅ |
| 48 | + imageUrl = s3Service.uploadFile(chatRoomRequest.getFile(), "chat-room"); // S3์ ์
๋ก๋ |
50 | 49 | }
|
51 | 50 |
|
52 | 51 | // ์ฑํ
๋ฐฉ ์์ฑ ์๋น์ค ํธ์ถ (์ด๋ฏธ์ง URL ํฌํจ)
|
|
0 commit comments