状态代码200,但获取存储错误



我正在使用dio向数据库发送请求。我试着上传一张图片;目的字段,并使用如下多部分文件发送到数据库:

uploadImages(token, productimage, purpose) async {
try {  
dio.options.headers['Authorization'] = 'Bearer $token';
print("___________IN upload images__________________");
String fileName = productimage.path.split('/').last;    
FormData formData = FormData.fromMap({
"productImage": 
await MultipartFile.fromFile(productimage.path, filename: fileName),
"purpose": purpose,
});
var b = await dio.post(
'api',
data: formData);
print(b.statusCode);
print(b);
print("___________IN upload images__________________");
return b;
} on DioError catch (e) {
print("Here I am in upload image error");
}

我已将文件质量限制为50,大小限制为500500,并使用image_picker拾取图像。我不知道为什么会出现存储错误。我在后台使用nodejs。我在fileName中获得了{scaled_IMG_220210603_233006.jpg},在productImage.path中获得了{/storage/emulated/0/Android/data.com/example.shop_app/files/Pictures/scaled_IMG_20210603~233006.jpg},并有意获得{"check"}。

编辑时间:当我设置内容类型时

dio.options.headers['Content-type'] = 'multipart/form-data';

我得到I/flutter (32229): 200 I/flutter (32229): {"error":{}}删除内容类型时我得到I/flutter (32229): 200 I/flutter (32229): {"error":{"storageErrors":[]}}当我设置内容类型时

dio.options.headers['Content-type'] = 'application/octet-stream';

我得到I/flutter (32229): 200 I/flutter (32229): Error: No File Selected

android清单文件中的所有存储权限。

最新更新