错误:发送base64发布请求Axios时,请求正文大于maxBodyLength限制

时间:2019-07-03 10:26:20

标签: node.js axios

在发送带有Base64编码的pdf作为正文的发布请求时,我收到错误消息

错误:请求正文大于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
            }
        });

有人可以解决吗?

2 个答案:

答案 0 :(得分:4)

那对我有用:

axios({
    method: 'post',
    url: posturl,
    data: formData,
    maxContentLength: Infinity,
    maxBodyLength: Infinity,
    headers: {'Content-Type': 'multipart/form-data;boundary=' + formData.getBoundary()}
})

答案 1 :(得分:1)

您正在设置

'maxContentLength': Infinity,
'maxBodyLength': Infinity

在您的数据对象中。它应该位于配置对象内部,外部数据对象。

相关问题