I have a Cloud Function that deletes the file from Cloud Storage
Function:
const { Storage } = require("@google-cloud/storage");
const storage = new Storage();
let handler = async (file, context) => {
console.log(` Event: ${context.eventId}`);
console.log(` Event Type: ${context.eventType}`);
console.log(` Bucket: ${file.bucket}`);
console.log(` File: ${file.name}`);
let bucket = storage.bucket(file.bucket);
let bucketFile = bucket.file(file.name);
bucketFile.delete();
};
I want to trigger this function after any file in the bucket is downloaded.
I've looked at the Cloud Storage triggers,
google.storage.object.finalize (default)
google.storage.object.delete
google.storage.object.archive
google.storage.object.metadataUpdate
but they don't work the way I want them to. Anyone have any suggestions?
Edit:
If I need to explain a little more what I want to do; Whether registered in our system or not, users are given links with some of their data openly to the public. Since these links may contain sensitive data, I would like to be granted a one-time download right. After a single download, the data needs to be permanently deleted.

