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

Function main

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

* This application demonstrates how to perform basic operations on bucket and * file Access Control Lists 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_print_bucket_acl]
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 printBucketAcl() {
40 try {
41 // Gets the ACL for the bucket
42 const [acls] = await storage.bucket(bucketName).acl.get();
43
44 acls.forEach(acl => {
45 console.log(`${acl.role}: ${acl.entity}`);
46 });
47 } catch (error) {
48 console.error(
49 'Error executing print bucket ACL:',
50 error.message || error
51 );
52 }
53 }
54 printBucketAcl();
55 // [END storage_print_bucket_acl]
56}
57
58main(...process.argv.slice(2));

Callers 1

printBucketAcl.jsFile · 0.70

Calls 1

printBucketAclFunction · 0.85

Tested by

no test coverage detected