-
Notifications
You must be signed in to change notification settings - Fork 1
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
[FEAT] 파일 PreSigned-Url 발급 API 개발 #119
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 0 additions & 13 deletions
13
src/main/java/site/katchup/katchupserver/api/card/dto/response/FileGetResponseDto.java
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
src/main/java/site/katchup/katchupserver/api/card/repository/FileRepository.java
This file was deleted.
Oops, something went wrong.
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
40 changes: 40 additions & 0 deletions
40
src/main/java/site/katchup/katchupserver/api/file/controller/FileController.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,40 @@ | ||
package site.katchup.katchupserver.api.file.controller; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.*; | ||
import site.katchup.katchupserver.api.file.dto.request.FileGetPreSignedRequestDto; | ||
import site.katchup.katchupserver.api.file.dto.response.FileGetPreSignedResponseDto; | ||
import site.katchup.katchupserver.api.file.service.FileService; | ||
import site.katchup.katchupserver.common.dto.ApiResponseDto; | ||
import site.katchup.katchupserver.common.util.MemberUtil; | ||
|
||
import java.security.Principal; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1") | ||
@Tag(name = "[File] 파일 관련 API (V1)") | ||
public class FileController { | ||
private final FileService fileService; | ||
|
||
@Operation(summary = "파일 Presigned-Url 요청 API") | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "파일 Presigned-Url 요청 성공"), | ||
@ApiResponse(responseCode = "400", description = "파일 Presigned-Url 요청 실패", content = @Content), | ||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) | ||
} | ||
) | ||
@GetMapping("/files/presigned") | ||
@ResponseStatus(HttpStatus.OK) | ||
public ApiResponseDto<FileGetPreSignedResponseDto> createPresigned(Principal principal, @RequestBody FileGetPreSignedRequestDto presignedRequestDto | ||
) { | ||
Long memberId = MemberUtil.getMemberId(principal); | ||
return ApiResponseDto.success(fileService.getFilePreSignedUrl(memberId, presignedRequestDto)); | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
src/main/java/site/katchup/katchupserver/api/file/dto/request/FileCreateRequestDto.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,31 @@ | ||
package site.katchup.katchupserver.api.file.dto.request; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.UUID; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@Schema(description = "파일 업로드 요청 DTO") | ||
public class FileCreateRequestDto { | ||
|
||
@Schema(description = "업로드하는 파일 고유 UUID", example = "ddwd-wdwd-wdwd-wdwdwdwd") | ||
@NotNull | ||
private UUID fileUUID; | ||
|
||
@Schema(description = "파일 이름", example = "와이어프레임 및 드라이브 사용법.pdf") | ||
@NotNull | ||
private String fileName; | ||
|
||
@Schema(description = "파일 url", example = "https://abde.s3.ap-northeast-2.amazonaws.com/1.pdf") | ||
@NotNull | ||
private String fileUrl; | ||
|
||
@Schema(description = "파일 사이즈 (KB 단위로 저장)", example = "189277") | ||
@NotNull | ||
private int size; | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...main/java/site/katchup/katchupserver/api/file/dto/request/FileGetPreSignedRequestDto.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,19 @@ | ||
package site.katchup.katchupserver.api.file.dto.request; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import static lombok.AccessLevel.PRIVATE; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = PRIVATE) | ||
@Schema(description = "파일 Presigned-Url 요청 DTO") | ||
public class FileGetPreSignedRequestDto { | ||
@Schema(description = "업로드하는 파일 이름", example = "와이어프레임 및 드라이브 사용법.pdf") | ||
@NotNull | ||
private String fileName; | ||
} |
24 changes: 24 additions & 0 deletions
24
...in/java/site/katchup/katchupserver/api/file/dto/response/FileGetPreSignedResponseDto.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,24 @@ | ||
package site.katchup.katchupserver.api.file.dto.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import static lombok.AccessLevel.PRIVATE; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = PRIVATE) | ||
@AllArgsConstructor(staticName = "of") | ||
@Schema(description = "파일 PreSigned-Url 응답 DTO") | ||
public class FileGetPreSignedResponseDto { | ||
|
||
@Schema(description = "파일 UUID", example = "file-uuid") | ||
private String fileUUID; | ||
|
||
@Schema(description = "파일 이름", example = "file-name") | ||
private String fileName; | ||
|
||
@Schema(description = "파일 PreSigned-Url", example ="preSigned-url") | ||
private String filePreSignedUrl; | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/site/katchup/katchupserver/api/file/dto/response/FileGetResponseDto.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,24 @@ | ||
package site.katchup.katchupserver.api.file.dto.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.UUID; | ||
|
||
@Getter | ||
@AllArgsConstructor(staticName = "of") | ||
public class FileGetResponseDto { | ||
@Schema(description = "파일 고유 id", example = "ddwd-wdwd-wdwd-wdwdwdwd") | ||
private UUID id; | ||
|
||
@Schema(description = "파일 이름", example = "와이어프레임 및 드라이브 사용법.pdf") | ||
private String name; | ||
|
||
@Schema(description = "파일 url", example = "https://abde.s3.ap-northeast-2.amazonaws.com/1.png") | ||
private String url; | ||
|
||
@Schema(description = "파일 사이즈 (KB 단위로 저장)", example = "189277") | ||
private int size; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/site/katchup/katchupserver/api/file/repository/FileRepository.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,20 @@ | ||
package site.katchup.katchupserver.api.file.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import site.katchup.katchupserver.api.file.domain.File; | ||
import site.katchup.katchupserver.api.screenshot.domain.Screenshot; | ||
import site.katchup.katchupserver.common.exception.NotFoundException; | ||
import site.katchup.katchupserver.common.response.ErrorCode; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public interface FileRepository extends JpaRepository<File, UUID> { | ||
|
||
List<File> findAllByCardId(Long cardId); | ||
|
||
default File findByIdOrThrow(UUID uuid) { | ||
return findById(uuid).orElseThrow( | ||
() -> new NotFoundException(ErrorCode.NOT_FOUND_FILE)); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p2;
statusCode와
@ResponseStatus
가 일치하지 않습니다~!