mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-07 01:26:43 +00:00
21 lines
651 B
JavaScript
21 lines
651 B
JavaScript
![]() |
/**
|
||
|
* Background Cloud Function to be triggered by Cloud Storage.
|
||
|
*
|
||
|
* @param {object} event The Cloud Functions event.
|
||
|
* @param {function} callback The callback function.
|
||
|
*/
|
||
|
exports.helloGCS = function (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();
|
||
|
};
|