Skip to content

Instantly share code, notes, and snippets.

@mfurlend
Created February 6, 2018 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfurlend/279386ee87cab9403c8f6fcf9d5b9152 to your computer and use it in GitHub Desktop.
Save mfurlend/279386ee87cab9403c8f6fcf9d5b9152 to your computer and use it in GitHub Desktop.
#cloud functions #trigger #cloud storage
exports.helloGCS = (event, callback) => {
const file = event.data;
if (file.resourceState === 'not_exists') {
console.log(`File ${file.name} deleted.`);
} else if (file.metageneration === '1') {
// metageneration attribute is updated on metadata changes.
// on create value is 1
console.log(`File ${file.name} uploaded.`);
} else {
console.log(`File ${file.name} metadata updated.`);
}
callback();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment