Skip to content

Commit

Permalink
remove unnecessary descriptions and add kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
m-p-esser committed Oct 7, 2023
1 parent b5c17c9 commit 7647c1c
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions src/etl/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,17 @@ def upload_blob_from_memory(
contents,
destination_blob_name: str,
gcp_credential_block_name: str,
**kwargs: dict,
) -> storage.bucket.Bucket.blob:
"""Uploads a file to the bucket."""

# The ID of your GCS bucket
# bucket_name = "your-bucket-name"

# The contents to upload to the file
# contents = "these are my contents"

# The ID of your GCS object
# destination_blob_name = "storage-object-name"

gcp_credentials = GcpCredentials.load(gcp_credential_block_name)
storage_client = gcp_credentials.get_cloud_storage_client()

bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(destination_blob_name)

blob.upload_from_string(contents)
blob.upload_from_string(contents, **kwargs)

return blob

Expand All @@ -39,21 +31,16 @@ def upload_blob_from_file(
source_file_name: str,
destination_blob_name: str,
gcp_credential_block_name: str,
**kwargs: dict,
) -> storage.bucket.Bucket.blob:
"""Uploads a file to the bucket."""
# The ID of your GCS bucket
# bucket_name = "your-bucket-name"
# The path to your file to upload
# source_file_name = "local/path/to/file"
# The ID of your GCS object
# destination_blob_name = "storage-object-name"

gcp_credentials = GcpCredentials.load(gcp_credential_block_name)
storage_client = gcp_credentials.get_cloud_storage_client()

bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(destination_blob_name)

blob.upload_from_filename(source_file_name)
blob.upload_from_filename(source_file_name, **kwargs)

return blob

0 comments on commit 7647c1c

Please sign in to comment.