错误:发送 base64 post 请求时请求正文大于 maxBodyLength 限制 Axios [英] Error: Request body larger than maxBodyLength limit when sending base64 post request Axios

查看:50
本文介绍了错误:发送 base64 post 请求时请求正文大于 maxBodyLength 限制 Axios的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当发送带有 Base64 编码的 pdf 作为正文的 post 请求时,我收到错误

When sending a post request with a Base64 encoded pdf as the body i recieve the error

错误:请求正文大于 maxBodyLength 限制

Error: Request body larger than maxBodyLength limit

我已经尝试设置以下两个

I have tried setting both of the following

'maxContentLength':无穷大,'maxBodyLength':无限

'maxContentLength': Infinity, 'maxBodyLength': Infinity

在请求配置中

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

有人有解决方法吗?

推荐答案

您正在设置

'maxContentLength': Infinity,
'maxBodyLength': Infinity

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

In your data object. It should be inside the config object, outside the data object.

这篇关于错误:发送 base64 post 请求时请求正文大于 maxBodyLength 限制 Axios的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆