首页 > 解决方案 > 错误:发送base64 post请求Axios时请求正文大于maxBodyLength限制

问题描述

当以 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
            }
        });

有人有解决方法吗?

标签: node.jsaxios

解决方案


你正在设置

'maxContentLength': Infinity,
'maxBodyLength': Infinity

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


推荐阅读