Store uploaded audio in GridFS instead of base64 inside the File document

オープン
#128 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, mongodb, next.js, node.js
領域
api, backend, database

調査の方向性

Read src/pages/api/files/index.js, src/pages/api/files/[id].js, and src/models/File.js, then trace the upload in src/pages/apps/musicplayer.js and the existing cases in tests/files.api.test.js. Start by checking the current upload and download flows and how MongoDB's GridFSBucket is used in the project. Done means large uploads work, Range requests stream only requested bytes, protections remain in place, existing tests pass with streaming, and the migration is documented.

索引モデルが issue の本文から書いたものです。

説明

backend difficulty: hard performance

New here? Say hi on Discord first, it's the fastest way to get help: https://discord.gg/NW2YZACf4k

Right now an uploaded song is stored as a base64 data URL in the content field of a File document. That works, but it has real limits:

  • MongoDB documents max out at 16 MB, so we cap uploads at 8 MB, and base64 makes files about 33% bigger.
  • Every request that loads the full File document drags the whole song along.
  • GET /api/files/:id decodes the entire file into memory even when the browser asks for a small byte range to seek.

Proposal

  • Store binary files (audio, images) in GridFS using the MongoDB driver's GridFSBucket. The File document keeps metadata and a reference such as gridfsId.
  • Make the upload a streaming multipart/form-data request instead of JSON. multer is already a dependency.
  • Make GET /api/files/:id stream from GridFS and pass Range requests through to openDownloadStream(id, { start, end }).
  • Keep the existing protections from #120: an allow-list of inline content types, nosniff, the sandbox CSP, and owner/collaborator checks.
  • Write a one-off migration script that moves existing base64 audio into GridFS.

Where: src/pages/api/files/index.js, src/pages/api/files/[id].js, src/models/File.js, and the upload in src/pages/apps/musicplayer.js.

Done when

  • Uploads of 30–50 MB work.
  • Seeking only reads the requested bytes.
  • The existing tests in tests/files.api.test.js still pass (adjusted for streaming).
  • The migration is documented in the PR.

This one is meatier. Talk it through on Discord before starting.


Comment "I'd like to take this" and we'll assign you. Questions are welcome in Discord: https://discord.gg/NW2YZACf4k

主要言語
JavaScript
スター
16
フォーク
8
平均マージ
4時間 24分
マージ済み PR(30日)
10

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

codehubbers/OrbitOS のほかの issue

codehubbers/OrbitOS の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。