✨feat: 프로필 이미지 업로드 기능 추가#14
Conversation
- Implemented OCIObjectStorageService to handle uploading and deleting profile images to Oracle Cloud Infrastructure (OCI) Object Storage. - Added methods for uploading images, deleting images, generating public URLs, and extracting object names from URLs. - Included error handling for OCI package import and object storage configuration. - Defined supported image file extensions for profile images.
| if not all((self.namespace, self.bucket, self.region)): | ||
| raise ObjectStorageError("OCI object storage is not configured") | ||
|
|
||
| config_file = os.getenv("OCI_CONFIG_FILE") |
There was a problem hiding this comment.
OCI_CONFIG_FILE 에 대해서 secret을 등록한거죠 지금 ? ?
OCI_CONFIG 자체를 불러오는게 만약 목적이라면, namespace, bucket, region은 하드코딩 or env 불러오는걸로 해도 될 거같고 InstancePrincipal 방식을 사용하는 것도 방법이 될수 있을것 같네요
나머지 public_base_url이나 이런것은 지금과 같이 해도 좋을것같습니다.
요거에서 InstancePrincipal을 이용하는걸 참고해보시면 좋을 것같아요
https://github.com/wafflestudio/waffle-world-oci/blob/main/argocd/siksha-prod/siksha-api-server.yaml (env에 등록은 여기에서)
# Conflicts: # pyproject.toml # uv.lock
| "ProjectService", | ||
| "MemberService", | ||
| "S3Service", | ||
| "OCIObjectStorageService", |
There was a problem hiding this comment.
S3Service, OCIObjectStorageService 이거 추상화 한번만 해주시겠어요 ?
혹시나 인프라 수정할 경우에 갈아끼기 쉽게 하는게 좋을것같아요
BucketService
ㄴ S3Service
ㄴ OCIObjectStorageService
| auth_mode = os.getenv("OCI_OBJECT_STORAGE_AUTH", "instance_principal") | ||
| try: | ||
| if auth_mode == "config_file": | ||
| config_file = os.getenv("OCI_CONFIG_FILE") |
There was a problem hiding this comment.
getenv 하면, https://github.com/wafflestudio/waffle-world-oci/blob/main/argocd/siksha-prod/siksha-api-server.yaml 여기에 환경변수를 주입해두는건데,
authMode 받는거 자체는 좋은데
이제 OCI_CONFIG_FILE은 getenv에서 가져오는게 아니라 아래와 같은 메소드 oci.config.from_file() 로 가져올수있어
이걸 가져오려면 InstancePrincipal이라는 노드에 인증 권한 주입이 필요한데 설명은 아래 참고
- InstancePrincipal : "OCI 컴퓨트 인스턴스(VM/노드) 자체에게 신원(identity)을 부여해서, API 키 없이도 그 인스턴스가 OCI 리소스에 접근할 수 있게 하는 인증 방식"
Infra 팀에서 oracle node 에 이미 instance principal 인증을 해두어서 가능합니다.
from config import (
OBJECT_STORAGE_BACKEND,
OBJECT_STORAGE_LOCAL_ROOT,
OBJECT_STORAGE_PUBLIC_BASE_URL,
OCI_OBJECT_STORAGE_AUTH,
OCI_OBJECT_STORAGE_BUCKET,
OCI_OBJECT_STORAGE_NAMESPACE,
OCI_OBJECT_STORAGE_REGION,
)
from error.exception.object_storage_error_503 import ObjectStorageClientException, ObjectStorageException
from util.ecs_log import logger
@lru_cache
def get_oci_object_storage_client():
import oci
if OCI_OBJECT_STORAGE_AUTH == "config_file":
config = oci.config.from_file()
return oci.object_storage.ObjectStorageClient(config)
What feature does this PR add?
Are there any caveats or things to watch out for?