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

Function main

storage-control/getFolder.js:17–50  ·  view source on GitHub ↗
(bucketName, folderName)

Source from the content-addressed store, hash-verified

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

Callers 1

getFolder.jsFile · 0.70

Calls 1

callGetFolderFunction · 0.85

Tested by

no test coverage detected