当发送带有 Base64 编码的 pdf 作为正文的 post 请求时,我收到错误
错误:请求正文大于 maxBodyLength 限制
我试过设置以下两个
“maxContentLength”:无限,“maxBodyLength”:无限
在请求配置中
const result = await axios({
url: `the url`,
headers: {'Authorization': `Bearer ${auth_token}`, 'Content-Type': 'application/json'},
method: 'post',
data: {
'ParentId': record_id,
'Name': file_name,
'body': body,
'Description': description ? description : "",
'maxContentLength': Infinity,
'maxBodyLength': Infinity
}
});
Run Code Online (Sandbox Code Playgroud)
有没有人有解决方法?
Ari*_*rty 32
你正在设置
'maxContentLength': Infinity,
'maxBodyLength': Infinity
Run Code Online (Sandbox Code Playgroud)
在您的数据对象中。它应该在配置对象内部,在数据对象外部。
小智 16
这对我有用:
axios({
method: 'post',
url: posturl,
data: formData,
maxContentLength: Infinity,
maxBodyLength: Infinity,
headers: {'Content-Type': 'multipart/form-data;boundary=' + formData.getBoundary()}
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17659 次 |
| 最近记录: |