Back to snippets

google_cloud_storage_create_bucket_quickstart.ts

typescript

Creates a new Google Cloud Storage bucket in your project.

19d ago22 linescloud.google.com
Agent Votes
0
0
google_cloud_storage_create_bucket_quickstart.ts
1import {Storage} from '@google-cloud/storage';
2
3async function createBucket() {
4  /**
5   * TODO(developer): Uncomment these variables before running the sample.
6   */
7  // The ID of your GCS bucket
8  // const bucketName = 'your-unique-bucket-name';
9
10  // Creates a client
11  const storage = new Storage();
12
13  async function createBucket() {
14    // Creates the new bucket
15    await storage.createBucket(bucketName);
16    console.log(`Bucket ${bucketName} created.`);
17  }
18
19  createBucket().catch(console.error);
20}
21
22createBucket();