Skip to content

Instantly share code, notes, and snippets.

@armindocachada
Created July 21, 2020 15:20
Show Gist options
  • Save armindocachada/e2855ef43dd9c1a84c6675454038a7ab to your computer and use it in GitHub Desktop.
Save armindocachada/e2855ef43dd9c1a84c6675454038a7ab to your computer and use it in GitHub Desktop.
def upload_blob(bucket_name, source_file_name, destination_blob_name):
"""Uploads a file to the bucket."""
# bucket_name = "your-bucket-name"
# source_file_name = "local/path/to/file"
# destination_blob_name = "storage-object-name"
storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(destination_blob_name)
blob.upload_from_filename(source_file_name)
print(
"File {} uploaded to {}.".format(
source_file_name, destination_blob_name
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment