简体   繁体   English

AWS S3 API - 按元数据搜索

[英]AWS S3 API - search by meta data

I use AWS s3 for storing few thousand files per hour and it works like a charm. 我使用AWS s3每小时存储几千个文件,它就像一个魅力。 I'm curious to see if I can filter them based on time or date or any meta data I have with these objects. 我很想知道我是否可以根据时间或日期或我对这些对象的任何元数据来过滤它们。 I'm able to run a node process to get the objects list and play around for date and time but not meta data. 我能够运行一个节点进程来获取对象列表并播放日期和时间而不是元数据。 Is there any other way do it or a better option ?. 还有其他办法或更好的选择吗?

No, you cannot filter on metadata with the S3 API. 不,您无法使用S3 API过滤元数据。

To do what you're asking, you would need to List Objects ( GET Bucket ) on the bucket to get all the keys, then individually ask for metadata for each key ( HEAD Object ). 要执行您要求的操作,您需要在存储上列出对象( GET Bucket )以获取所有密钥,然后单独询问每个密钥的元数据( HEAD对象 )。 Then in your own code, you can filter out objects that don't match. 然后在您自己的代码中,您可以过滤掉不匹配的对象。

Obviously, this would be very slow to run live if you have more than a few thousand objects. 显然,如果你有超过几千个对象,这将是非常慢的运行。 You'll want to either filter down to a manageable number based on prefix or keep an index yourself (elastic search, maybe?). 你想要根据前缀过滤到可管理的数字,或者自己保留一个索引(弹性搜索,也许?)。 It's common to encode some metadata in the object keys so that you can filter by prefix. 在对象键中编码一些元数据是很常见的,这样您就可以按前缀进行过滤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM