如何在 node.js 的 amazon s3 中获取存储桶中任何资源的最后访问日期?

How to get the last access date of any resource in a bucket in amazon s3 in node.js?

我正在尝试获取存储桶中资源的最后访问日期。但无法找到与之相关的任何内容。我尝试获取存储桶的所有访问日志并解析日志文件以检查是否访问了资源。

这是一个非常复杂的方法。在

s3.listObjects 我得到以下对象:-

 { Key: '_636579271588176973_951622.json',
       LastModified: 2018-08-02T08:31:29.000Z,
       ETag: '"c348574fabf83d603984a60983add161"',
       Size: 32172,
       StorageClass: 'STANDARD',
       Owner: [Object] },

S3 只是 AWS 的对象存储解决方案,因此不保存文件访问时间等信息。

一如既往,有解决方法可以实现这一点,

  • 您可以设置 CloudTrail to get last access date to a resource based on resource type. Read more here.
  • 您可以使用 Server Access Logging on your bucket, and parse the logs to extract your last access date for the object. Read more here