获取Golang中S3对象的过期时间

huangapple go评论86阅读模式
英文:

get s3 object expiration in golang

问题

似乎有一种方法可以通过在PutObjectInput中附加一个带有"expdays"键的元数据来设置上传的过期天数,但似乎没有办法从像"ListObjects"调用中的对象中获取此元数据。ListObjectOutput返回的是一个s3.Objects列表,但该对象没有元数据字段,我也没有看到其他获取它的方法。

英文:

There seems to be a way to set expiration days in an upload by attaching a Metadata with an "expdays" key to the PutObjectInput but there doesn't appear to be any way to then get this metadata from an object in like a "ListObjects" call. ListObjectOutput returns "Contents" which is a list of s3.Objects but that object doesn't have a metadata field and I don't see any other way to get it either.

答案1

得分: 2

ListObjects调用返回结果中的实际对象列表[]Object,而Object不包含过期时间。然而,GetObject返回GetObjectOutput,它包含一个Expiration字段。因此,您可以迭代返回的Object,并获取每个对象的过期时间,但如果对象很多,这可能会耗费时间。

英文:

The ListObjects calls return a []Object for the actual object list in the result, and Object does not include the expiration. However, GetObject returns GetObjectOutput which does have an Expiration field. So you could iterate your returned Objects and get the expiration for each, though this could be time-consuming if there are many of them.

huangapple
  • 本文由 发表于 2017年7月7日 03:51:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/44957724.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定