HussainLatiff commited on
Commit
3fcf795
Β·
verified Β·
1 Parent(s): e5c7f94

Update AzureBlobStorageVideo.py

Browse files
Files changed (1) hide show
  1. AzureBlobStorageVideo.py +21 -19
AzureBlobStorageVideo.py CHANGED
@@ -13,29 +13,31 @@ target_container_id = 'useruploadhuggingfacevideo'
13
 
14
 
15
 
16
- def deleteUserVideoFromBlobStorage(container_id: str) -> None:
17
- """
18
- Deletes all blobs within a specified Azure Blob Storage container.
19
 
20
- Args:
21
- container_id (str): The ID of the container to delete.
22
- """
23
- try:
24
- # Establish connection using your storage connection string (replace with yours)
25
- storage_connection_string = '<connection string>'
26
- blob_service_client = azure.storage.blob.BlobServiceClient.from_connection_string(storage_connection_string)
 
 
 
 
 
 
 
 
 
27
 
28
- # Get container client
29
- container_client = blob_service_client.get_container_client(container_id)
30
 
31
- # Delete all blobs in the container (iterator for large datasets)
32
- blobs = container_client.list_blobs()
33
- for blob in blobs:
34
- container_client.delete_blob(blob.name)
35
- print(f'Container "{container_id}" emptied successfully.')
36
 
37
- except Exception as e:
38
- print(f'Error deleting blobs: {e}')
39
 
40
 
41
  def uploadUserVideoToBlobStorage(file_path, file_name):
 
13
 
14
 
15
 
16
+ def delete_container(container_id: str) -> None:
17
+ """
18
+ Deletes all blobs within a specified Azure Blob Storage container.
19
 
20
+ Args:
21
+ container_id (str): The ID of the container to delete.
22
+ """
23
+ try:
24
+ # Establish connection using your storage connection string (replace with yours)
25
+ storage_connection_string = 'DefaultEndpointsProtocol=https;AccountName=useruploadhuggingface;AccountKey=zhrGpPBX6PVD+krncC4nVF4yoweEku/z2ErVxjLiuu/CjAVKqM5O4xlGWEyuWGxptL3mA1pv/6P4+AStjSjLEQ==;EndpointSuffix=core.windows.net'
26
+ blob_service_client = azure.storage.blob.BlobServiceClient.from_connection_string(storage_connection_string)
27
+
28
+ # Get container client
29
+ container_client = blob_service_client.get_container_client(container_id)
30
+
31
+ # Delete all blobs in the container (iterator for large datasets)
32
+ blobs = container_client.list_blobs()
33
+ for blob in blobs:
34
+ container_client.delete_blob(blob.name)
35
+ print(f'Container "{container_id}" emptied successfully.')
36
 
37
+ except Exception as e:
38
+ print(f'Error deleting blobs: {e}')
39
 
 
 
 
 
 
40
 
 
 
41
 
42
 
43
  def uploadUserVideoToBlobStorage(file_path, file_name):