已从 Firebase 存储迁移到 Supabase
Migrate Firebase Storage files to Supabase Storage.
Supabase 提供了几种 工具 来将存储文件从 Firebase Storage 转换到 Supabase Storage。转换是一个两步的过程:
🌐 Supabase provides several tools to convert storage files from Firebase Storage to Supabase Storage. Conversion is a two-step process:
- 文件从 Firebase 存储桶下载到本地文件系统。
- 文件会从本地文件系统上传到 Supabase 存储桶。
设置迁移工具 #
🌐 Set up the migration tool [#set-up-migration-tool]
-
克隆
firebase-to-supabase仓库:1git clone https://github.com/supabase-community/firebase-to-supabase.git -
在
/storage目录中,将 supabase-keys-sample.js 重命名为supabase-keys.js。 -
在仪表板中进入你 Supabase 项目的 API 设置。
-
复制 项目 URL 并更新
supabase-keys.js中的SUPABASE_URL值。 -
在 项目 API 密钥 下,复制 密钥 并更新
supabase-keys.js中的SUPABASE_KEY值。
生成一个 Firebase 私钥 #
🌐 Generate a Firebase private key [#generate-firebase-private-key]
- 登录你的 Firebase 控制台 并打开你的项目。
- 点击侧边栏 项目概览 旁边的齿轮图标,然后选择 项目设置。
- 点击 服务账户,然后选择 Firebase 管理 SDK。
- 点击 生成新的私钥。
- 把下载的文件重命名为
firebase-service.json。
命令行选项 #
🌐 Command line options
将 Firestore Storage 桶下载到本地文件夹 #
🌐 Download Firestore Storage bucket to a local filesystem folder [#download-firestore-storage-bucket]
node download.js <prefix> [<folder>] [<batchSize>] [<limit>] [<token>]
<prefix>:要下载的文件前缀。要处理根存储桶,请使用空前缀:""。<folder>:(可选) 用于已下载文件的子文件夹名称。所选的文件夹会被创建在当前文件夹下(例如:./downloads/)。默认是downloads。<batchSize>:(可选) 默认值是100。<limit>:(可选) 处理这么多文件后停止。若不限数量,请使用0。<token>:(可选) 从这个pageToken开始处理。
要使用多次命令行执行来批量处理,你必须在后续调用中使用相同的参数并带上新的 <token>。使用上一次调用显示的令牌可以在指定点继续处理。
🌐 To process in batches using multiple command-line executions, you must use the same parameters with a new <token> on subsequent calls. Use the token displayed on the last call to continue the process at a given point.
将文件上传到 Supabase Storage 存储桶 #
🌐 Upload files to Supabase Storage bucket [#upload-to-supabase-storage-bucket]
node upload.js <prefix> <folder> <bucket>
<prefix>:要下载的文件前缀。要处理所有文件,请使用空前缀:""。<folder>:要上传文件的子文件夹名称。选中的文件夹会被当作当前文件夹的子文件夹读取(例如,./downloads/)。默认是downloads。<bucket>:要上传的桶的名称。
如果桶不存在,它会被创建为一个 non-public 桶。你必须在 Supabase 控制台 上为这个新桶设置权限,用户才能下载任何文件。
🌐 If the bucket doesn't exist, it's created as a non-public bucket. You must set permissions on this new bucket in the Supabase Dashboard before users can download any files.
资源 #
🌐 Resources
迁移到 Supabase #
🌐 Migrate to Supabase
如果你在迁移项目时需要更多帮助,联系我们。