请帮忙
我从客户端接收图像并将其保存在文件系统中的服务器上并处理此图像,然后我需要将其上传到 firebase 存储
我尝试在异步函数中从 Node.js 上传图像文件到 firebase 存储
const path = process.cwd() + '/my_image.jpg';
const file = readFileSync(path);
await firebase.storage().ref().child('my_image.jpg').put(file);
...
Run Code Online (Sandbox Code Playgroud)
但我有错误
第一个参数必须是字符串类型或 Buffer 的实例。接收到一个 Uint8Array 的实例
好吧,我尝试二进制格式
const path = process.cwd() + '/my_image.jpg';
const file = readFileSync(path, { encoding: 'base64' });
await firebase.storage().ref().child('my_image.jpg').putString(file, 'base64');
...
Run Code Online (Sandbox Code Playgroud)
我得到错误
Firebase 存储:字符串与格式“base64”不匹配:找到无效字符”
我已经尝试了很多东西,但没有任何效果!我究竟做错了什么?