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

Unable to Upload Files Larger than 2GB to Firebase Storage

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

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
firebase, node.js, typescript
领域
backend, cloud

调研方向

从提供的 uploadFileViaStream 函数开始,在 Node.js 上使用一个超过 2GB 的文件重现 Firebase Storage SDK 10.12.2 中的失败,然后将其与所述的 1.8GB 情况进行比较。跟踪 Gaxios EPROTO 请求,以确定问题是在 SDK 的上传路径中,还是在其使用方式中;当原因和受支持的解决方案得到明确确立时,即表示完成。

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

描述

needs-triage
[REQUIRED] Step 2: Describe your environment

Operating System

  • MAC OS SONOMA 14.5

Browser Version

  • ARC (CHROME)

Firebase SDK Version

  • 10.12.2

Firebase SDK Product:

  • Storage

NPM and NODE:
I'm using nestJS (@10.3.9), nodeJS (v20.11.1) and npm 10.2.4

[REQUIRED] Step 3: Describe the problem

I am experiencing an issue where attempting to upload files larger than 2GB to Firebase Storage results in a GaxiosError: request to https://storage.googleapis.com/upload/storage/v1/b/[...] failed, reason: write EPROTO.

However, smaller files (e.g., 1.8GB) upload without any issues.

Steps to reproduce:
  1. Attempt to upload a file larger than 2GB using the Firebase Storage SDK in a Node.js application.
  2. Encounter the following error:
Failed to upload file. GaxiosError: request to [https://storage.googleapis.com/upload/storage/v1/b/...] failed, reason: write EPROTO
at Gaxios._request (/path/to/project/node_modules/gaxios/src/gaxios.ts:157:13)
type: 'system',
errno: 'EPROTO',
code: 'EPROTO'
Relevant Code:

Here is a sample of the TypeScript function used for uploading:

import { Stream } from 'stream';
import { getStorageAdmin } from 'path-to-your-storage-admin-utils';

async uploadFileViaStream(fileStream: Stream, path: string): Promise<string> {
    console.debug('Uploading file to storage using stream...');
    const storage = getStorageAdmin();
    const bucket = storage.bucket('voicecheap-c1f14.appspot.com');
    const fileRef = bucket.file(path);
    const contentType =
      path.split('.').pop() === 'mp3' ? 'audio/mpeg' : 'video/mp4';

    // Verify if the file already exists
    const [exists] = await fileRef.exists();
    if (exists) {
      console.debug('File already exists. Skipping upload.');
      return fileRef.publicUrl();
    }

    return new Promise((resolve, reject) => {
      fileStream
        .pipe(
          fileRef.createWriteStream({
            contentType: contentType,
            public: true,
            metadata: {
              contentType: contentType,
              mimeType: contentType,
              type: contentType,
            },
          }),
        )
        .on('error', (error) => {
          console.error('Failed to upload file.', error);
          reject(error);
          throw new InternalServerErrorException('Failed to upload file.');
        })
        .on('finish', async () => {
          // Make the file publicly accessible
          try {
            await fileRef.makePublic();
            console.debug('File uploaded and made public.');
            resolve(fileRef.publicUrl());
          } catch (error) {
            console.error('Failed to make the file public.', error);
            reject(error);
            throw new InternalServerErrorException(
              'Failed to make the file public.',
            );
          }
        });
    });
  }
主要语言
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 摘要。