Check if bucket exists
Updated at:2025-11-03
If users need to determine whether a bucket exists, the following code can achieve this:
Plain Text
1 # To obtain the existence information of a bucket, you need to pass in the bucket name, and the return value is a boolean type
2 exists = bos_client.does_bucket_exist(bucket_name)
3# Output result
4 if exists:
5 print("Bucket exists")
6 else:
7 print("Bucket not exists")
