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

Function main

storage-control/createFolder.js:17–51  ·  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_create_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 be created
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 callCreateFolder() {
36 const bucketPath = controlClient.bucketPath('_', bucketName);
37
38 // Create the request
39 const request = {
40 parent: bucketPath,
41 folderId: folderName,
42 };
43
44 // Run request
45 const [response] = await controlClient.createFolder(request);
46 console.log(`Created folder: ${response.name}.`);
47 }
48
49 callCreateFolder();
50 // [END storage_control_create_folder]
51}
52
53process.on('unhandledRejection', err => {
54 console.error(err.message);

Callers 1

createFolder.jsFile · 0.70

Calls 1

callCreateFolderFunction · 0.85

Tested by

no test coverage detected