简体   繁体   English

如何使用 Google Cloud Storage 中的元数据进行排序和过滤?

[英]How to sort and filter using metadata in Google Cloud Storage?

I am using metadata on blobs in a Google Cloud Storage bucket to store important information regarding a specific blob.我在 Google Cloud Storage 存储桶中使用 blob 的元数据来存储有关特定 blob 的重要信息。 I would like to use the Sort and filter functionality that is available from the Cloud Storage UI a bit more extensively.我想更广泛地使用 Cloud Storage UI 提供的Sort and filter功能。 The available filter properties seem to be:可用的过滤器属性似乎是:

  • Name contains名称包含
  • Name prefix名称前缀
  • Size (bytes)大小(字节)
  • Type类型
  • Created on创建于
  • Created before创建于
  • Created after创建于
  • Storage class仓储 class
  • Last modified on最后修改于
  • Last modified before最后修改时间早于
  • Last modified after最后修改时间晚于
  • Public access公共访问
  • Version history版本历史
  • Encryption加密
  • Retention expires on保留期满
  • Retention expires before保留期限早于
  • Retention expires after保留期满后
  • Holds举行

But no filter property for metadata is available.但是没有元数据的过滤器属性可用。 However, some functionality to filter on metadata seems to be present.但是,似乎存在一些过滤元数据的功能。 For example.例如。 If there are two files present, one with the metadata key-value pair special_key: true and the other one no metadata tag and I filter (in the UI) with Sort and filter , special_key then the only file that remains is the one with the tag.如果存在两个文件,一个具有元数据键值对special_key: true ,另一个没有元数据标记,我使用Sort and filter过滤(在 UI 中), special_key那么唯一剩下的文件就是带有标签。

However, I cannot filter more specifically on the label, for example special_key = true to only show the blobs with a certain value of a metadata key.但是,我无法在 label 上进行更具体的过滤,例如special_key = true以仅显示具有特定元数据键值的 blob。 Is there a way to do this?有没有办法做到这一点? A similar question has been asked here , but the best answer solves this by using the SDK and not the UI itself, which is the preferred solution. 此处提出了类似的问题,但最佳答案是使用 SDK 而不是 UI 本身来解决此问题,这是首选解决方案。

As mentioned in the document :文档中所述:

In the Cloud Console list of objects for a bucket, you can filter the objects you see by specifying a prefix in the Filter by object or folder name prefix... text box, located above the list of objects.在存储桶的 Cloud Console 对象列表中,您可以通过在位于对象列表上方的过滤条件 object 或文件夹名称前缀... 文本框中指定前缀来过滤您看到的对象。 This filter displays objects beginning with the specified prefix.此过滤器显示以指定前缀开头的对象。 The prefix only filters objects in your current bucket view: it does not select objects contained in folders.前缀仅过滤当前存储桶视图中的对象:它不过滤文件夹中包含的 select 个对象。

For your case, you can do this answer_1 and answer_2 :对于您的情况,您可以执行此answer_1answer_2

You would need to list all the objects and then filter at the client side.您需要列出所有对象,然后在客户端进行过滤。 Another option, if it's possible to rename your objects, would be to construct your object names such that the metadata values on which you want to filter are built into the beginning of the object names.如果可以重命名您的对象,另一种选择是构造您的 object 名称,以便将要过滤的元数据值内置到 object 名称的开头。 You could then use a prefix filter on the listing request.然后,您可以对列表请求使用前缀过滤器。

There is one Public issue tracker created on the similar issue, you can take a look .有一个针对类似问题创建的公共问题跟踪器,您可以看一看

For more information, you can refer to the documentation .更多信息,您可以参考文档

how about: GCS --> Cloud Functions --> some database;怎么样:GCS --> Cloud Functions --> 一些数据库; use the db index for filtering/searching使用数据库索引进行过滤/搜索

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

相关问题 如何使用 Python aiohttp PATCH 请求通过 Google Cloud Storage 更新 object 元数据? - How can I update an object metadata through Google Cloud Storage using Python aiohttp PATCH request? 可以添加文件但不能在谷歌云存储中设置元数据 - Can add file but cannot set metadata in Google Cloud Storage 如何使用 Python API 在 Google Cloud Storage 上上传文件夹 - How to upload folder on Google Cloud Storage using Python API 获取/设置谷歌云存储中的元数据 - node.js - Getting/Setting metadata in google cloud storage - node.js 如何将本地存储(活动存储)迁移到谷歌云存储 - How to migrate local storage (active storage) to google cloud storage 如何在angular中使用谷歌云存储的签名URL下载文件 - How to download a file using the signed URL of google cloud storage in angular 如何使用 Cloud Function 服务帐户在 Cloud Function 中创建签名的 Google Cloud Storage URL? - How to create signed Google Cloud Storage URLs in Cloud Function using Cloud Function service account? 如何在 Google Cloud Storage 中下载多个文件 - How to download multiple files in Google Cloud Storage 如何将文件上传到 Python 3 上的 Google Cloud Storage? - How to upload a file to Google Cloud Storage on Python 3? 如何从谷歌云存储下载? - How to download from google cloud storage?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM