Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

FR: Support direct lookup of Storage objects by `metadata.id`

未关闭
#2,939 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
google-cloud, node.js, typescript
领域
api, backend, cloud

调研方向

从 Admin SDK 的 Bucket 类开始,追踪它如何创建文件引用;将这一路径与 issue 中提到的底层 @google-cloud/storage 客户端进行比较。定义如何支持 metadata.id 查找,然后验证返回的对象是否像 bucket.file(path) 一样支持 getMetadata()、download() 和 getSignedUrl()。

由索引模型根据 Issue 内容生成。

描述

type: feature request

Title:
FR: Support direct lookup of Storage objects by metadata.id


Is your feature request related to a problem? Please describe.
Currently in the Admin SDK there is no way to fetch a file reference directly by its internal metadata.id. Users must call bucket.getFiles() (optionally with a prefix) and then iterate through every file’s metadata until they find a match. This approach is painfully inefficient for buckets with hundreds or thousands of objects, and leads to high latency and extra egress charges just to resolve a single file by its ID.


Describe the solution you’d like
Add a first-class API—e.g.

const file = await bucket.fileById('ABCD1234-xyz');

under the Admin SDK’s Bucket class (and optionally in the underlying @google-cloud/storage client). Internally it could leverage a server-side lookup or index rather than requiring a full listing scan. The returned object should behave identically to bucket.file(path) so you can immediately call getMetadata(), download(), or getSignedUrl().


Describe alternatives you’ve considered

  • Client-side scan:

    const [files] = await bucket.getFiles();
    for (const f of files) {
      const [m] = await f.getMetadata();
      if (m.id === targetId) return f;
    }
    

Works, but requires listing every object + extra round-trips.

  • Storing custom metadata: You could save your own “id” in metadata.custom and index it in Firestore, but that duplicates what the server already knows, and still needs a separate database lookup.

Additional context

  • This feature is especially important for multi-tenant or large-scale apps where buckets routinely hit thousands of files.
  • Without it, reverse-lookup patterns become a maintenance burden and performance bottleneck.
  • Screenshot of current workaround and templates attached.
主要语言
TypeScript
星标
1.7k
派生
419
平均合并
4 天 20 小时
30 天内合并 PR
16

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

firebase/firebase-admin-node 的其他 Issue

查看 firebase/firebase-admin-node 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。