Reputation: 23
I'm building an application using Google Cloud Storage where users will be able to share their files with other users for a period of time that they choose. After that, the permission to view the file will be revoked.
One way would be to generate signed urls and share those. However, I'd like to use ACL instead since it's much cleaner to use I think. When a user shares a file I can simply add the new user to the ACL with an expiry time. So basically, the following code with some kind of a time attribute to automatically remove user1 from the acl after, say, t seconds.
storage
.bucket(bucketName)
.file(filename)
.acl.readers.addUser(user1)
.then(() => {
console.log(`Added user ${user1} as an owner on file ${filename}.`);
})
.catch(err => {
console.error('ERROR:', err);
});
Is this possible?
Upvotes: 1
Views: 211
Reputation: 29591
It is not possible via builtin functionality. You would have to use some third-party scheduling service, create a cron job that checks for expired ACLs every so often, or create a mirco-service that monitors your ACLs expiration table and automatically removes when expiry occurs.
Upvotes: 1