MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

storage/quickstart.js:17–49  ·  view source on GitHub ↗
(bucketName = 'my-new-bucket')

Source from the content-addressed store, hash-verified

15'use strict';
16
17function main(bucketName = 'my-new-bucket') {
18 // [START storage_quickstart]
19 // Imports the Google Cloud client library
20 const {Storage} = require('@google-cloud/storage');
21
22 // For more information on ways to initialize Storage, please see
23 // https://googleapis.dev/nodejs/storage/latest/Storage.html
24
25 // Creates a client using Application Default Credentials
26 const storage = new Storage();
27
28 // Creates a client from a Google service account key
29 // const storage = new Storage({keyFilename: 'key.json'});
30
31 /**
32 * TODO(developer): Uncomment these variables before running the sample.
33 */
34 // The ID of your GCS bucket
35 // const bucketName = 'your-unique-bucket-name';
36
37 async function createBucket() {
38 try {
39 // Creates the new bucket
40 await storage.createBucket(bucketName);
41 console.log(`Bucket ${bucketName} created.`);
42 } catch (error) {
43 console.error('Error executing create bucket:', error.message || error);
44 }
45 }
46
47 createBucket();
48 // [END storage_quickstart]
49}
50
51main(...process.argv.slice(2));

Callers 1

quickstart.jsFile · 0.70

Calls 1

createBucketFunction · 0.70

Tested by

no test coverage detected