我想将图像从android设备上传到节点服务器。目前,我正在将图像转换为Base64字符串,并使用AsyncTask传递它。我不了解服务器端发生了什么。当我将请求正文登录到控制台时,它显示“未定义”。
这是用于将图像转换为Base64字符串并上传到节点服务器的android代码:
这是接收图像数据后的控制台输出:
这是服务器代码:
如何纠正错误? 也欢迎其他任何建议。
答案 0 :(得分:0)
您需要安装body-parser模块
要安装
npm i -s body-parser
然后
在app.post路由之前设置以下配置
// support parsing of application/json type post data
app.use(bodyParser.json());
//support parsing of application/x-www-form-urlencoded post
app.use(bodyParser.urlencoded({
parameterLimit: 100000,
limit: '150mb',
extended: true
}));