youngtsai commited on
Commit
910748f
·
1 Parent(s): 357dba3

def delete_blob(self, bucket_name, blob_name):

Browse files
Files changed (1) hide show
  1. storage_service.py +11 -0
storage_service.py CHANGED
@@ -24,6 +24,12 @@ class GoogleCloudStorage:
24
  blob.upload_from_string(content)
25
  print(f"String content uploaded to {destination_blob_name} in GCS.")
26
  return None
 
 
 
 
 
 
27
 
28
  def download_as_string(self, bucket_name, source_blob_name):
29
  blob = self.client.bucket(bucket_name).blob(source_blob_name)
@@ -42,3 +48,8 @@ class GoogleCloudStorage:
42
  self.upload_file(bucket_name, file_name, file_path)
43
  self.make_blob_public(bucket_name, file_name)
44
  return self.get_public_url(bucket_name, file_name)
 
 
 
 
 
 
24
  blob.upload_from_string(content)
25
  print(f"String content uploaded to {destination_blob_name} in GCS.")
26
  return None
27
+
28
+ def upload_json_string(self, bucket_name, destination_blob_name, json_data):
29
+ """Uploads a JSON string to a specified GCS bucket."""
30
+ blob = self.client.bucket(bucket_name).blob(destination_blob_name)
31
+ blob.upload_from_string(json_data, content_type='application/json')
32
+ print(f"JSON string uploaded to {destination_blob_name} in GCS.")
33
 
34
  def download_as_string(self, bucket_name, source_blob_name):
35
  blob = self.client.bucket(bucket_name).blob(source_blob_name)
 
48
  self.upload_file(bucket_name, file_name, file_path)
49
  self.make_blob_public(bucket_name, file_name)
50
  return self.get_public_url(bucket_name, file_name)
51
+
52
+ def delete_blob(self, bucket_name, blob_name):
53
+ blob = self.client.bucket(bucket_name).blob(blob_name)
54
+ blob.delete()
55
+ print(f"Blob {blob_name} deleted from {bucket_name}.")