-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* refactor: 기록 생성 api에서 video multipart 대신 videoUrl 받도록 수정 * refactor: s3Service video upload 로직 제거 및 presignedUrl 생성 로직 추가 * refactor: s3Service 로직 변경에 따른 RecordService 리팩토링 * feat: s3 presignedUrl 생성 api 추가 * fix: presingedUrl에서 videoUrl 추출하는 과정 중 발생한 버그 수정 * add: signIn, signUp response body에 memberId 추가 (#103) * fix: @ModelAttribute -> @requestbody로 변경
- Loading branch information
Showing
9 changed files
with
125 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/com/climingo/climingoApi/upload/api/S3Controller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.climingo.climingoApi.upload.api; | ||
|
||
import com.climingo.climingoApi.upload.S3Service; | ||
import com.climingo.climingoApi.upload.api.request.PresignedUrlCreateRequest; | ||
import com.climingo.climingoApi.upload.api.response.PresignedUrlResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class S3Controller { | ||
|
||
private final S3Service s3Service; | ||
|
||
@PostMapping("/s3/presigned-url") | ||
public ResponseEntity<PresignedUrlResponse> generatePresignedUrl( | ||
@RequestBody PresignedUrlCreateRequest request) { | ||
String presignedUrl = s3Service.generatePresignedUrl(request).toString(); | ||
String videoUrl = parseUrlWithoutQuery(presignedUrl); | ||
|
||
return ResponseEntity.ok(new PresignedUrlResponse(presignedUrl, videoUrl)); | ||
} | ||
|
||
private String parseUrlWithoutQuery(String url) { | ||
int queryIndex = url.indexOf("?"); | ||
|
||
if (queryIndex != -1) { | ||
return url.substring(0, queryIndex); | ||
} | ||
|
||
return url; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/climingo/climingoApi/upload/api/request/PresignedUrlCreateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.climingo.climingoApi.upload.api.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class PresignedUrlCreateRequest { | ||
|
||
@NotNull | ||
private String fileName; | ||
|
||
@NotNull | ||
private String extension; | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/climingo/climingoApi/upload/api/response/PresignedUrlResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.climingo.climingoApi.upload.api.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class PresignedUrlResponse { | ||
|
||
private final String presignedUrl; | ||
private final String videoUrl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters