Multer将文件上传到对象数组中

我有一个这样的对象数组:

data: [
    {"image": File,"certificate": File},{"image": File,"certificate": File}
]

我读取服务器上文件的方式是在发送POST请求之前进行循环:

...
const fd = new FormData();
fd.append('image',data[0].image);
fd.append('image',data[1].image);
fd.append('certificate',data[0].certificate);
fd.append('certificate',data[1].certificate);
this.http.post('http://localhost:3000/upload',fd,options);

然后在服务器端我做

upload.fields([{ name: 'image',maxCount: 2 },{ name: 'certificate',maxCount: 2 }])

所以我的问题是...如果我发送像这样的数组,有没有办法

fd.append('data',data)

因此multer可以将数据字段中的文件取走吗?

nathansgl 回答:Multer将文件上传到对象数组中

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3095099.html

大家都在问