Check Bucket Availability
Using the head_bucket() SDK method, you can check the existence of a bucket in Stratus, and further check if the user has the relevant permissions to access the objects present in the bucket. The stratus reference used in the below code snippet is the component instance.
Possible responses when using this SDK:
-
If the bucket exists and if the user has the relevant permissions to access the bucket, the response ‘true’ will be returned.
-
If the bucket does not exist, or if the user does not have permission to access the bucket, the response ‘false’ will be returned.
Parameters Used
Parameter Name | Data Type | Definition |
---|---|---|
bucket_name | String | A Mandatory parameter. Will hold the unique name of the bucket. |
throw_err | Boolean | An Optional parameter. If you set this parameter as "true", then it will throw an error when the bucket is not found in the project. The default value is "false" |
copybucket_res = stratus.head_bucket('bucket_name', throw_err=False) print(bucket_res)
Possible Errors
Note: If you use the SDK with the throw_err parameter, and the bucket does not exist, or if you do not have sufficient permissions then you may encounter any of the errors listed below.
Error Code | Meaning |
---|---|
404 | Not Found. Bucket Not found in Stratus. |
401 | Unauthorized/Access Denied - User doesn't have permission to perform the particular operation. |
403 | Permission Denied - User does not have permission to access the particular bucket. |
Last Updated 2025-06-20 16:21:48 +0530 +0530
Yes
No
Send your feedback to us
Skip
Submit