(bucketName, folderName)
| 15 | 'use strict'; |
| 16 | |
| 17 | function 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 | |
| 53 | process.on('unhandledRejection', err => { |
| 54 | console.error(err.message); |
no test coverage detected