Skip to content

Commit

Permalink
Merge pull request #49 from galadriel-ai/updates-gcp-credentials
Browse files Browse the repository at this point in the history
Updates gcp credentials
  • Loading branch information
KasparPeterson authored Apr 1, 2024
2 parents e028f7d + 475257b commit 89c82c3
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 89c82c3

Please sign in to comment.