项目里用到与服务端交互图片,flutter formdata数据交互方法
FormData formdata = FormData.fromMap(
{"file": await MultipartFile.fromFile(path, filename: name)});
Response response = await dio
.post(baseUrl + UrlManager.uploadUserAvatar,
data: formdata, options: options)
.catchError((e) {
});
之前在header里加了content-type,后来发现flutter如果判断是formdata的会帮我们进行content-type设置
网友评论