@google-cloud-suite/cloud-functions-update-storage-metadata
v0.0.37
Published
@google-cloud-suite/cloud-functions-update-storage-metadata
Downloads
7
Readme
@google-cloud-suite/cloud-functions-update-storage-metadata
Update object metadata with created trigger.
What is this?
- Save
file.txt.metadata
on your bucket
{
"contentDisposition": "attachment:filename=textfile.txt"
}
- When
file.txt
is created, this function set metadata fromfile.txt.metadata
tofile.txt
.
How to use?
- Prepare your Google Cloud Functions directory.
functions
|- package.json
|- index.js
|- .gcloudignore
...
- Install
npm install @google-cloud-suite/cloud-functions-update-storage-metadata
- Handle stroage trigger
You can use handleStorageObjectCreated(params: InitParams)
to initialize trigger. The followings are the property of InitParams:
- metadataFileSuffix?: string
- defaults:
.metadata
- defaults:
Examples:
- Using event target bucket for both source and destination.
const updateMetadata = require("@google-cloud-suite/cloud-functions-update-storage-metadata");
exports.updateMetadata = updateMetadata.handleStorageObjectCreated();
- Deploy
gcloud functions deploy updateMetadata \
--runtime nodejs10 \
--trigger-resource YOUR_BUCKET \
--trigger-event google.storage.object.finalize \
--project YOUR_PROJECT