Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log('This is a deletion event.');
return;
}
// Construct a Cloud Vision request
let req = {
image: {
source: {
gcsImageUri: util.format('gs://%s/%s', fileBucket, filePath)
}
},
features: [{ type: 'LABEL_DETECTION' }]
};
// Make the Cloud Vision request
return vision.annotate(req)
.then(function(data) {
let annotations = data[0];
let apiResponse = data[1];
let err = _.get(apiResponse, 'responses[0].error');
if (err) {
throw new Error(err.message);
}
// Save the annotations into the file in the database
let labelAnnotations = _.get(annotations, '[0].labelAnnotations');
if (labelAnnotations) {
return admin.database().ref().child('tags/'+pathMap.postId).update(labelAnnotations);
}
});
});