Skip to content

Commit

Permalink
Updates gcp credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
KasparPeterson committed Apr 1, 2024
1 parent e028f7d commit 475257b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion oracles/src/domain/storage/reupload_to_gcp_use_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
import settings
from typing import Optional
from google.cloud import storage
from google.oauth2 import service_account
from urllib.parse import urlparse, unquote

KEY_PATH = "/app/sidekik.json"


async def _generate_filename(original_filename: str) -> str:
_, extension = os.path.splitext(original_filename)
Expand All @@ -25,7 +28,12 @@ async def execute(download_url: str) -> Optional[str]:
if response.status == 200:
image_data = await response.read()

storage_client = storage.Client()
credentials = service_account.Credentials.from_service_account_file(
KEY_PATH)
storage_client = storage.Client(
project="sidekik-ai",
credentials=credentials,
)
bucket = storage_client.bucket(settings.GCS_BUCKET_NAME)
blob = bucket.blob(new_image_name)
blob.upload_from_string(
Expand Down

0 comments on commit 475257b

Please sign in to comment.