-
Notifications
You must be signed in to change notification settings - Fork 0
/
gcs.py
22 lines (19 loc) · 847 Bytes
/
gcs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from google.cloud import storage
def upload_blob(bucket_name, source_file_name, destination_blob_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(f"File {source_file_name} uploaded to {destination_blob_name}.")
def make_blob_public(bucket_name, blob_name):
storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(blob_name)
blob.make_public()
#print(f"Blob {blob.name} is publicly accessible at {blob.public_url}")
def delete_blob(bucket_name, blob_name):
storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(blob_name)
blob.delete()
#print(f"Blob {blob_name} deleted.")