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

Function main

storage/enableRequesterPays.js:25–56  ·  view source on GitHub ↗

* This application demonstrates how to perform basic operations on buckets with * the Google Cloud Storage API. * * For more information, see the README.md under /storage and the documentation * at https://cloud.google.com/storage/docs.

(bucketName = 'my-bucket')

Source from the content-addressed store, hash-verified

23 */
24
25function main(bucketName = 'my-bucket') {
26 // [START storage_enable_requester_pays]
27 /**
28 * TODO(developer): Uncomment the following lines before running the sample.
29 */
30 // The ID of your GCS bucket
31 // const bucketName = 'your-unique-bucket-name';
32
33 // Imports the Google Cloud client library
34 const {Storage} = require('@google-cloud/storage');
35
36 // Creates a client
37 const storage = new Storage();
38
39 async function enableRequesterPays() {
40 try {
41 await storage.bucket(bucketName).enableRequesterPays();
42
43 console.log(
44 `Requester-pays requests have been enabled for bucket ${bucketName}`
45 );
46 } catch (error) {
47 console.error(
48 'Error executing enable requester pays:',
49 error.message || error
50 );
51 }
52 }
53
54 enableRequesterPays();
55 // [END storage_enable_requester_pays]
56}
57main(...process.argv.slice(2));

Callers 1

Calls 1

enableRequesterPaysFunction · 0.85

Tested by

no test coverage detected