GCP Object Storage
This package is intended for use in GCP Cloud Functions and to write and read JavaScript objects as JSON files to/from Cloud Storage.
Installation
npm install gcp-object-storage
Usage
JavaScript
const gcpObjectStorage = 'gcp-object-storage';const objectReader = ;const objectWriter = ; const options = contentType: 'application/x-font-ttf' metadata: my: 'custom' properties: 'go here' public: true; // providing optional metadataobjectWriter; // without metadataobjectWriter; objectReader;// Object { any: "data" }
TypeScript
; ;new ObjectWriter .writeObject, 'my-gcp-bucket', 'folder/to/my/file.json', options .thennew ObjectReader.readObject'my-gcp-bucket', 'folder/to/my/file.json' .thenconsole.logdata;// Object { any: "data" }
Test
npm run test