【问题标题】:Google Cloud Storage ACL with expiry time具有到期时间的 Google Cloud Storage ACL
【发布时间】:2018-03-30 22:08:26
【问题描述】:

我正在使用 Google Cloud Storage 构建一个应用程序,用户可以在该应用程序中与其他用户共享他们选择的一段时间内的文件。之后,查看文件的权限将被撤销。

一种方法是生成signed urls 并分享它们。 但是,我想改用ACL,因为我认为它使用起来更干净。当用户共享文件时,我可以简单地将新用户添加到具有到期时间的 ACL。 所以基本上,下面的代码带有某种时间属性,可以在 t 秒之后自动从 acl 中删除 user1。

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);
  });

这可能吗?

【问题讨论】:

    标签: javascript node.js google-cloud-platform google-cloud-storage


    【解决方案1】:

    这是不可能通过内置功能实现的。您将不得不使用一些第三方调度服务,创建一个定期检查过期 ACL 的 cron 作业,或者创建一个监控 ACL 过期表并在过期时自动删除的 mirco-service。

    【讨论】:

      猜你喜欢
      • 2012-11-16
      • 2015-05-15
      • 2014-10-09
      • 2015-02-15
      • 2019-05-17
      • 1970-01-01
      • 1970-01-01
      • 2015-11-16
      • 2012-12-01
      相关资源
      最近更新 更多