What is Cloud Storage bucket or What is bucket storage?
To store data on the cloud 'storage space' is provided by different cloud platforms, like in the case of Google 'cloud storage space' is called Bucket. You can use Google Cloud bucket to store any kind of file and folder of data. In the GCS bucket, you can store data like Images, Audio, Video, Project files, and any other types of files.
There is no limit on the amount of data you can keep in GCS also there is no limit on no of GCS Buckets you can create on the Google cloud platform. One thing to note is that name of Google Bucket/GCS Bucket should be unique across google cloud i.e., your Bucket name should not match with any other google account Bucket name.
How to Create Google Cloud Storage bucket Using Python?
Prerequisite -
Note: You will get 'service account json keys' from your google cloud account
Step 1
Install Required python libraries
pip install google-cloud
pip install google-cloud-storage
from google.cloud import storage
def create_bucket(bucket_name):
#Use ServiceAccount key file to Create a client which intreact with the GCS/Google Cloud Storage API
client = storage.Client.from_service_account_json('C:\\Users\\hp\\Downloads\\avid-influence-39XXXX-XXXXXXXXXXXX.json')
# Mention location parameter to create new bucket
bucket = client.create_bucket(bucket_name, location='us-central1')
print(f"Bucket {bucket.name} created.")
if __name__ == "__main__":
# Mention below name of Bucket you want to create on Google Cloud
bucket_name = "ABBCCDDTest1"
create_bucket(bucket_name)
After running Step 2, you should get message - Bucket ABBCCDDTest1 created
Send Query