Skip to content
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

✨ use oracle object storage to upload image #426

Merged
merged 4 commits into from
Dec 3, 2024
Merged

✨ use oracle object storage to upload image #426

merged 4 commits into from
Dec 3, 2024

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Nov 26, 2024

S3 를 사용하던 이미지 업로드/조회를 Object Storage를 사용하도록 변경했습니다.
기본적인 로직은 기존 로직과 동일합니다.

S3에서 presigned url이었던 업로드용 url을 Object Storage의 PAR로 변경했고,
변경이 용이하게 하기 위해 인터페이스로 추상화했습니다.
어떤 구현체를 사용할지는 ImageConfig에서 주입해서 정할 수 있습니다.
UserService, RecipeService, RecipeStepService는 이제 우리가 S3를 쓰는지 Object Storage를 쓰는지 모릅니다!!!!!!
(멋지죠...)

변경사항은 다음과 같습니다.
기존에는 AWS S3에 요청을 전송하는 서버 자체로 인증을 했으나, 현재는 API key를 발급받아 이것을 직접 사용합니다.

참고자료
오라클 공식문서
Maven 버전

@github-actions github-actions bot added ✨ feature new feature BE Backend labels Nov 26, 2024
Copy link
Contributor Author

Overall Project 89.88% -1.05% 🍏
Files changed 71.08% 🍏

File Coverage
ImageController.java 100% 🍏
UploadUrlResponse.java 100% 🍏
RecipeStepService.java 95.65% 🍏
LoginService.java 93.36% 🍏
UserService.java 93.33% 🍏
RecipeService.java 88.19% 🍏
ImageConfig.java 85.11% -14.89% 🍏
ObjectStorageClientService.java 48.1% -51.9% 🍏

Copy link

@HaiSeong HaiSeong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아토 폰드 수고 많았습니다.
말씀하신것처럼 이미지 업로드 서비스에대한 강결합이 제거되고 의존성이 사라진 부분이 만족스러운 코드네요!
몇가지 궁굼한 점이 있어서 질문 남깁니다.
고생많으셨어요!

Comment on lines -2 to +6
id 'java'
id 'org.springframework.boot' version '3.2.7'
id 'io.spring.dependency-management' version '1.1.5'
id 'jacoco'
id 'com.epages.restdocs-api-spec' version '0.18.2'
id 'java'
id 'org.springframework.boot' version '3.2.7'
id 'io.spring.dependency-management' version '1.1.5'
id 'jacoco'
id 'com.epages.restdocs-api-spec' version '0.18.2'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기존은 tab 기반으로 gradle 작성했었고 변경된건 스페이스4개 기준이네요.
혹시 어떤게 컨벤션에 맞는건가요?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gradle indent 컨벤션에 대해서 저희끼리 논의해봐야 할 것 같아요😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기를 보면 스페이스 4개가 컨벤션같아요~~

private final S3ClientService s3ClientService;
private final ImageClientService imageClientService;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines 43 to 45
} catch (Exception e) {
throw new RuntimeException("Failed to load private key", e);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

예외가 터졌을때 Oracle Object Storage 문제라는것을 바로 알 수 있게 메시지에 추가하는것도 좋아보입니다!
물론 에외에 이미 나와있을것 같아서 선택적으로 반영하면 좋을것 같아요!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추가적으로 예외 메시지가 한글인 게 좋을 것 같아 이 코멘트를 반영하며 함께 수정했습니다!

@Value("${oracle.cloud.url-prefix}")
private String urlPrefix;

private static final int DURATION_SECONDS = 600;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 시간은 어떤값인가요? 600인 기준은 어떤 이유인가요?
또는 이 값을 yaml로 이동시키는것도 고려 해보셨나요!?

Copy link
Contributor

@tackyu tackyu Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이미지 업로드를 위해 제공하는 PAR의 만료 시간입니다.
펭쿡이 이전에 사용하던 presigned url에 부여하던 만료기한 규칙과 동일하게 적용했습니다.

yaml로 해당 값을 관리하는게 유지보수에 더 용이하겠네요! 감사합니다

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 동의해서 수정했습니다~~

Comment on lines +56 to +61
return new ImageUrlResponse(String.format("%s/n/%s/b/%s/o/%s",
client.getEndpoint(),
namespace,
bucketName,
fileName));
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/n/은 어떤 의미인가요?

Copy link
Contributor

@tackyu tackyu Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오라클에서 제공하는 url 형식입니다
리소스 식별하는 구분자로 사용됩니다!
/n namespace
/b buckeName
/o object

@HaiSeong HaiSeong self-requested a review November 28, 2024 10:45
@hyxrxn hyxrxn closed this Nov 29, 2024
@hyxrxn hyxrxn deleted the be/feat/425 branch November 29, 2024 01:25
@hyxrxn hyxrxn restored the be/feat/425 branch November 30, 2024 14:06
@hyxrxn hyxrxn reopened this Nov 30, 2024
Copy link
Contributor Author

Overall Project 89.88% -1.05% 🍏
Files changed 71.08% 🍏

File Coverage
ImageController.java 100% 🍏
UploadUrlResponse.java 100% 🍏
RecipeStepService.java 95.65% 🍏
LoginService.java 93.36% 🍏
UserService.java 93.33% 🍏
RecipeService.java 88.19% 🍏
ImageConfig.java 85.11% -14.89% 🍏
ObjectStorageClientService.java 48.1% -51.9% 🍏

Copy link
Contributor Author

Overall Project 89.88% -1.05% 🍏
Files changed 71.08% 🍏

File Coverage
ImageController.java 100% 🍏
UploadUrlResponse.java 100% 🍏
RecipeStepService.java 95.65% 🍏
LoginService.java 93.36% 🍏
UserService.java 93.33% 🍏
RecipeService.java 88.19% 🍏
ImageConfig.java 85.11% -14.89% 🍏
ObjectStorageClientService.java 48.1% -51.9% 🍏

Copy link
Contributor

@geoje geoje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
추상화 😮😮😮

Copy link
Contributor Author

github-actions bot commented Dec 3, 2024

Overall Project 89.84% -1.09% 🍏
Files changed 70.24% 🍏

File Coverage
ImageController.java 100% 🍏
UploadUrlResponse.java 100% 🍏
RecipeStepService.java 95.65% 🍏
LoginService.java 93.36% 🍏
UserService.java 93.33% 🍏
RecipeService.java 88.19% 🍏
ImageConfig.java 85.11% -14.89% 🍏
ObjectStorageClientService.java 46.91% -53.09% 🍏

@tackyu tackyu merged commit ea70a28 into be/dev Dec 3, 2024
1 check passed
@tackyu tackyu deleted the be/feat/425 branch December 3, 2024 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BE Backend ✨ feature new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants