可以获取多个 AWS S3 对象的头部(元数据)吗?

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

is it possible to fetch multiple aws s3 object head (metadata)?

问题

我正在使用AWS S3将我的终端用户文件存储在一个存储桶中。我的后端是用Golang编写的。

在我的Web界面中,我希望用户能够在其个人空间中查看其文件和文件夹的名称、MIME类型、大小和最后修改日期。为了实现这一点,我看到了以下代码:

func (c *S3) HeadObject(input *HeadObjectInput) (*HeadObjectOutput, error)

如果我想获取单个文件的元数据,这个函数很好用,但是我找不到获取多个文件元数据的等效函数。

类似于ListObjectsV2的函数可以使用前缀和分隔符来缩小搜索范围,但不返回文件的完整内容,这将是完美的。

如果没有用于获取多个文件元数据的端点,最好的方法是什么?

谢谢!

英文:

I'm using AWS S3 to store my end-users' files in a single Bucket. My backend is in Golang.

In my web interface, I want any user in its personal space to be able to see its files and folders names, MIME type, size and last modified date. To achieve this I saw:

func (c *S3) HeadObject(input *HeadObjectInput) (*HeadObjectOutput, error)

It's nice if I want to get a single file metadata but I can't find an equivalent for multiple files.

Something of the kind of ListObjectsV2 where I can use prefixes and delimiters to narrow the search but without the full content of the files would be perfect.

If there isn't an endpoint to fetch multiple files metadata, what could be the best approach ?

Thanks !

答案1

得分: 0

以下是您可以从S3获取的系统定义的元数据列表:

  1. 列表项
  2. 内容长度
  3. 最后修改时间
  4. 内容类型
  5. 内容MD5
  6. x-amz-server-side-encryption
  7. x-amz-version-id
  8. x-amz-delete-marker
  9. x-amz-storage-class
  10. x-amz-website-redirect-location
  11. x-amz-server-side-encryption-aws-kms-key-id
  12. x-amz-server-side-encryption-customer-algorithm

如果您想要的是headObject(metadata),HEAD操作可以从对象中检索元数据,而不返回对象本身。如果您只对对象的元数据感兴趣,这个操作非常有用。

请参考下面的文档

编辑:来自AWS文档的一些示例代码

可以获取多个 AWS S3 对象的头部(元数据)吗?

英文:

The following list of system-defined metadata you could get from S3.

  1. List item
  2. Content-Length
  3. Last-Modified
  4. Content-Type
  5. Content-MD5
  6. x-amz-server-side-encryption
  7. x-amz-version-id
  8. x-amz-delete-marker
  9. x-amz-storage-class
  10. x-amz-website-redirect-location
  11. x-amz-server-side-encryption-aws-kms-key-id
  12. x-amz-server-side-encryption-customer-algorithm

if you're looking for is headObject(metadata) the HEAD operation retrieves metadata from an object without returning the object itself. This operation is useful if you're only interested in an object's metadata.

please refer below Document

edit: some sample code from aws doc

可以获取多个 AWS S3 对象的头部(元数据)吗?

huangapple
  • 本文由 发表于 2021年12月31日 15:32:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/70540012.html
匿名

发表评论

匿名网友

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

确定