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

Function main

storage-control/listFolders.js:18–50  ·  view source on GitHub ↗
(bucketName)

Source from the content-addressed store, hash-verified

16'use strict';
17
18function main(bucketName) {
19 // [START storage_control_list_folders]
20 /**
21 * TODO(developer): Uncomment these variables before running the sample.
22 */
23
24 // The name of your GCS bucket
25 // const bucketName = 'bucketName';
26
27 // Imports the Control library
28 const {StorageControlClient} = require('@google-cloud/storage-control').v2;
29
30 // Instantiates a client
31 const controlClient = new StorageControlClient();
32
33 async function callListFolders() {
34 const bucketPath = controlClient.bucketPath('_', bucketName);
35
36 // Create the request
37 const request = {
38 parent: bucketPath,
39 };
40
41 // Run request
42 const [folders] = await controlClient.listFolders(request);
43 for (const curFolder of folders) {
44 console.log(curFolder.name);
45 }
46 }
47
48 callListFolders();
49 // [END storage_control_list_folders]
50}
51
52process.on('unhandledRejection', err => {
53 console.error(err.message);

Callers 1

listFolders.jsFile · 0.70

Calls 1

callListFoldersFunction · 0.85

Tested by

no test coverage detected