exports.uploadFile = async (req, res) => {
let form = new formidable.IncomingForm();
form.keepExtensions = true;
form.parse(req, (err, feilds, files) => {
if (err) {
return res.status(400).json({ error: "could not be uploaded" });
}
storageRef.child("projects").child("project_id").child("file_id").put(files.file)
});
};
我使用此代码上传了要在邮递员上进行即时测试的文件。该错误表明
message_: 'Firebase Storage: Invalid argument in `put` at index 0: Expected Blob or File.',
当我console.log(files.file)时,它表明它确实是一个文件。我在nodejs中这样做。
File {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
size: 16,
path: '/var/folders/vr/81h88st96j15mnzm09jd5nch0000gn/T/upload_5fef8e0ca74c1034ef0a8a2815964dd3.txt',
name: 'sample3.txt',....
}
我该如何解决?