当我尝试点击 post call 并将输入文件作为 formdata 发送时,我正面临 400 状态代码,如下所示。任何人都可以帮我解决这个问题吗?
const file = req['file'].buffer.toString('base64');
const formData = new FormData();
formData.append('file', file);
axios.post('http://localhost:8082/postFile',formData,
{
headers: {
'Content-Type':'multipart/form-data; boundary='+timestamp
}
})
.then((response) => {
console.log("RESPONSE RECEIVED: ", response);
})
.catch((err) => {
console.log("AXIOS ERROR: ", err);
});
data: {
timestamp: '2021-05-26T14:54:37.560+0000',
status: 400,
error: 'Bad Request',
message: "Required request part 'file' is not present",
path: '/postFile'
}