如何将BLOB格式的图像上传到Firebase存储?

时间:2019-02-17 17:30:52

标签: node.js firebase google-cloud-storage admin-sdk

我在SQLite数据库中有一个BLOB类型的图像,我想将该图像上传到Firebase存储中,获取图像的下载URL和尺寸并将它们添加到Firebase实时数据库中。我已经使用bucket.upload从本地驱动器成功上传了图像,但是我不知道如何上传blob。

我在服务器端(NodeJS)上使用admin-sdk,有一个“ put”功能,但是在客户端sdk中。

bucket.upload("./file.jpeg", options).then(result => {
  const file = result[0];
  console.log(file)
}).then(results => {
  console.log(results);
}).catch(error => {
  console.error(error);
});

1 个答案:

答案 0 :(得分:0)

如果要直接发送Blob,则必须使用流传输。有一个第三方库提供此功能:https://cloud.google.com/storage/docs/boto-plugin#streaming-transfers