-
Notifications
You must be signed in to change notification settings - Fork 1
[FEAT] #179: swagger 설정 추가 #192
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
502f6e8
feat(#179/resources): .env 불러오는 설정 추가
kaswhy 293678b
refactor(#179/resources): util, config 파일 global로 이동
kaswhy 9174c0b
refactor(#189/*): aws s3 관련 의존성 업데이트
kaswhy b5e1f41
feat(#179/global): swagger 관련 설정 추가
kaswhy e29bfa0
feat(#179/global): 전체 api 그룹 추가
kaswhy 1fd75c2
feat(#179/*): .gitignore에 .env.properties 추가
kaswhy 2815d7a
feat(#179/config): swagger 전체 그룹 기본 빌더 반환으로 변경
kaswhy 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 hidden or 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 |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ HELP.md | |
| **/.env.* | ||
| *.env | ||
| .env | ||
| .env.properties | ||
| !.env.example | ||
| **/.env.example | ||
| build/ | ||
|
|
||
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
src/main/java/inha/gdgoc/domain/auth/service/RefreshTokenService.java
This file contains hidden or 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
38 changes: 19 additions & 19 deletions
38
src/main/java/inha/gdgoc/domain/resource/service/S3Service.java
This file contains hidden or 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 |
|---|---|---|
| @@ -1,43 +1,43 @@ | ||
| package inha.gdgoc.domain.resource.service; | ||
|
|
||
| import com.amazonaws.services.s3.AmazonS3; | ||
| import com.amazonaws.services.s3.model.ObjectMetadata; | ||
| import inha.gdgoc.domain.resource.enums.S3KeyType; | ||
| import java.io.IOException; | ||
| import java.util.UUID; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.web.multipart.MultipartFile; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.UUID; | ||
| import software.amazon.awssdk.core.sync.RequestBody; | ||
| import software.amazon.awssdk.services.s3.S3Client; | ||
| import software.amazon.awssdk.services.s3.model.GetUrlRequest; | ||
| import software.amazon.awssdk.services.s3.model.PutObjectRequest; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class S3Service { | ||
|
|
||
| private final AmazonS3 amazonS3; | ||
| private final S3Client s3Client; | ||
|
|
||
| @Value("${cloud.aws.s3.bucket}") | ||
| private String bucketName; | ||
|
|
||
| public String upload( | ||
| Long userId, | ||
| S3KeyType s3key, | ||
| MultipartFile file | ||
| ) throws IOException { | ||
| public String upload(Long userId, S3KeyType s3key, MultipartFile file) throws IOException { | ||
| String fileName = UUID.randomUUID() + "-" + file.getOriginalFilename(); | ||
| String prefix = "user/" + userId + "/"; | ||
| String uploadFilePath = prefix + s3key.getValue() + "/" + fileName; | ||
| String key = "user/%d/%s/%s".formatted(userId, s3key.getValue(), fileName); | ||
|
|
||
| ObjectMetadata metadata = new ObjectMetadata(); | ||
| metadata.setContentLength(file.getSize()); | ||
| metadata.setContentType(file.getContentType()); | ||
| PutObjectRequest putReq = PutObjectRequest.builder() | ||
| .bucket(bucketName) | ||
| .key(key) | ||
| .contentType(file.getContentType()) | ||
| .build(); | ||
|
|
||
| amazonS3.putObject(bucketName, uploadFilePath, file.getInputStream(), metadata); | ||
| return uploadFilePath; | ||
| s3Client.putObject(putReq, RequestBody.fromInputStream(file.getInputStream(), file.getSize())); | ||
| return key; | ||
kaswhy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| public String getS3FileUrl(String key) { | ||
| return amazonS3.getUrl(bucketName, key).toString(); | ||
| return s3Client.utilities() | ||
| .getUrl(GetUrlRequest.builder().bucket(bucketName).key(key).build()) | ||
| .toExternalForm(); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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
2 changes: 1 addition & 1 deletion
2
.../inha/gdgoc/config/jwt/JwtProperties.java → ...dgoc/global/config/jwt/JwtProperties.java
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
.../inha/gdgoc/config/jwt/TokenProvider.java → ...dgoc/global/config/jwt/TokenProvider.java
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.