首页 > 解决方案 > 如何替换 Firebase 存储桶上的文件?

问题描述

我正在从 node.js 服务器将图像上传到我的 firebase 存储桶,如下所示:

bucket.upload(files.image.path, {metadata: {contentType: files.image.type}});

A 还想替换已经上传的文件。例如,如果我编辑文件并想上传新版本,则覆盖旧版本。

我在谷歌上读到我可以通过指定旧文件的名称来替换文件,但我尝试了以下似乎不起作用的方法:

bucket.upload(files.image.path, {metadata: {contentType: files.image.type, name: fields.filename}});

...但它告诉我:

Value 'upload_8b8702384ca2686b8a0a0de7102f2804' in content does not agree with value 'upload_73065f47da4149eee391cd09a01f628a'. This can happen when a value set through a parameter is inconsistent with a value set in the request.

什么是正确的方法?

谢谢

标签: javascriptfirebasegoogle-cloud-storagefirebase-storage

解决方案


推荐阅读