* This application demonstrates how to perform basic operations on buckets 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.
(projectId, bucketName = 'my-bucket')
| 23 | */ |
| 24 | |
| 25 | function main(projectId, bucketName = 'my-bucket') { |
| 26 | // [START storage_disable_requester_pays] |
| 27 | |
| 28 | /** |
| 29 | * TODO(developer): Uncomment the following lines before running the sample. |
| 30 | */ |
| 31 | // The ID of your Google Cloud project |
| 32 | // const projectId = 'your-project-id'; |
| 33 | |
| 34 | // The ID of your GCS bucket |
| 35 | // const bucketName = 'your-unique-bucket-name'; |
| 36 | |
| 37 | // Imports the Google Cloud client library |
| 38 | const {Storage} = require('@google-cloud/storage'); |
| 39 | |
| 40 | // Creates a client |
| 41 | const storage = new Storage(); |
| 42 | |
| 43 | async function disableRequesterPays() { |
| 44 | try { |
| 45 | // Disables requester-pays requests |
| 46 | await storage |
| 47 | .bucket(bucketName) |
| 48 | .disableRequesterPays({userProject: projectId}); |
| 49 | |
| 50 | console.log( |
| 51 | `Requester-pays requests have been disabled for bucket ${bucketName}` |
| 52 | ); |
| 53 | } catch (error) { |
| 54 | console.error( |
| 55 | 'Error executing disable requester pays:', |
| 56 | error.message || error |
| 57 | ); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | disableRequesterPays(); |
| 62 | // [END storage_disable_requester_pays] |
| 63 | } |
| 64 | main(...process.argv.slice(2)); |
no test coverage detected