这是我带有标头auth
令牌的邮递员请求。
我正在尝试上传图片,一切都按照 dio docs 中的说明进行设置,并且与 postman 参数完全相同,但抛出 500 错误,在这里找不到任何错误。在这里被困了3个小时。
请在这里找到任何错误我被困在这里谢谢!(ps:postaman 文件只需要图像文件,即 jpg、png 其他文件不包括图像也会抛出与应用程序抛出的 500 错误相同的错误)
我的 dio 要求是:
Future requestChangePhoto(
String wardenToken, String wardenId, File imageFile) async {
String fileName = imageFile.path.split('/').last;
print(fileName);
print(getWardenPhotoChange);
FormData data = FormData.fromMap({
"wardenId": "${wardenId.trim()}",
"photo": await MultipartFile.fromFile(imageFile.path,
filename: fileName, contentType: MediaType("image", "jpg")),
});
Dio dio = new Dio();
dio.options.headers['content-Type'] = 'application/json';
dio.options.headers["authorization"] = "$wardenToken";
await dio
.post("$getWardenPhotoChange", data: data)
.then((response) => print(response.data));
}
这是我的ImagePicker
要求:
var imageFile = await ImagePicker.pickImage(source: imageType == ImageType.camera? ImageSource.camera: ImageSource.gallery,
imageQuality: 50, maxHeight: 500, maxWidth: 500
);
print(imageFile);
NetworkHandler networkHandler = NetworkHandler();
networkHandler.requestChangePhoto(xybaData.WardenToken, xybaData.wardernId, imageFile);
这是我的错误: