【问题标题】:Firebase storage: file().move is not implemented?Firebase 存储:file().move 未实现?
【发布时间】:2021-12-19 10:01:08
【问题描述】:

我正在使用 firebase 模拟器进行本地开发。

前端应用程序创建一个项目,其中一些文件上传到存储桶中的“tmp/”文件夹。

项目保存后,我需要将上传的文件移动到项目文件夹中。但是在做(云功能)时

const storage = new Storage();
// also tried:
// const storage = admin.storage();

const bucket = storage.bucket(DEFAULT_BUCKET);
const destRoot = `${project.id}/files`;

// `tmpFiles` is an array of file paths
const movedfiles = await Promise.all(
  tmpFiles.map((file: string) =>
    bucket
      .file(`tmp/${file}`) 
      .move(`${destRoot}/${file}`)
      .then((result) => result[0].publicUrl())
      .catch(console.log)
  )
);

我收到了这个错误 ApiError: file#copy failed with an error - Not Implemented

所以暂时无法移动存储文件?

【问题讨论】:

    标签: firebase google-cloud-platform google-cloud-functions google-cloud-storage


    【解决方案1】:

    Firebase 模拟器通常只/首先实现客户端 SDK 中也可能执行的操作。由于 Cloud Storage 的客户端 SDK 没有用于移动文件的 API,因此在使用 Admin SDK 时,该操作(目前)也未在模拟器中实现。

    此特定功能在 Github 存储库中被跟踪为 #3751,因此我建议在那里查看更新,或提交 PR 添加该功能。

    【讨论】:

      猜你喜欢
      • 2020-08-08
      • 2021-08-15
      • 2020-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-20
      • 1970-01-01
      相关资源
      最近更新 更多