【发布时间】:2020-07-07 13:37:35
【问题描述】:
我正在使用flutter开发一个应用程序,我正在使用http库来调用我构建的api。
我想发出一个多部分请求来发送文件,它也发送它,但我无法从服务器收到任何响应,因为返回的对象是 StreamResponse。
请告诉我如何获取响应的正文。
代码片段:
var request = http.MultipartRequest('POST', Uri.parse('$SERVER_URL/signup'));
request.files.add(await http.MultipartFile.fromPath(
'image',
user.image,
filename: 'image',
contentType: MediaType('multipart/form-data', 'multipart/form-data'),
));
StreamResponse x = await request.send();
//get body of the response
谢谢,
【问题讨论】: