flutter dio upload image type application/octet-stream to image/jpeg
高端VPN,微科 VPN 专线VPN,独立IP TikTok梯子,独享60元/月包年高速直连, 流畅播放Youtube 8K 视频不满意随时退款, QQ 2553878266
MediaType? mediaType;
if (_fileToUpload.path.endsWith('jpg') ||
_fileToUpload.path.endsWith('jpeg')) {
mediaType = MediaType("image", "jpeg");
} else if (_fileToUpload.path.endsWith('png')) {
mediaType = MediaType("image", "png");
}
if (_fileToUpload.path.isNotEmpty) {
// Create a FormData
String fileName = basename(_fileToUpload.path);
print("File Name : $fileName");
print("File Size : ${_fileToUpload.lengthSync()}");
print("File Type : $mediaType");
_formData = FormData.fromMap({
"product_images": await MultipartFile.fromFile(_fileToUpload.path,
filename: fileName, contentType: mediaType)
});
}
解决方案就是更改contentType参数
评论
登陆评论
没有评论