英文:
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获取的系统定义的元数据列表:
- 列表项
- 内容长度
- 最后修改时间
- 内容类型
- 内容MD5
- x-amz-server-side-encryption
- x-amz-version-id
- x-amz-delete-marker
- x-amz-storage-class
- x-amz-website-redirect-location
- x-amz-server-side-encryption-aws-kms-key-id
- x-amz-server-side-encryption-customer-algorithm
如果您想要的是headObject(metadata),HEAD操作可以从对象中检索元数据,而不返回对象本身。如果您只对对象的元数据感兴趣,这个操作非常有用。
请参考下面的文档。
编辑:来自AWS文档的一些示例代码
英文:
The following list of system-defined metadata you could get from S3.
- List item
- Content-Length
- Last-Modified
- Content-Type
- Content-MD5
- x-amz-server-side-encryption
- x-amz-version-id
- x-amz-delete-marker
- x-amz-storage-class
- x-amz-website-redirect-location
- x-amz-server-side-encryption-aws-kms-key-id
- 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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论