我看到了其他的类似问题,但那并不是我想要的,我不想将图片上传到服务器,也不想转换为base64...
我只想以表单数据或其他方式发布文件,并获得返回的信息。
我有这个代码,但它没有起作用:
void onTakePictureButtonPressed() {
takePicture().then((String filePath) {
if (mounted) {
setState(() {
imagePath = filePath;
videoController?.dispose();
videoController = null;
});
http.post('http://ip:8082/composer/predict', headers: {
"Content-type": "multipart/form-data",
}, body: {
"image": filePath,
}).then((response) {
print("Response status: ${response.statusCode}");
print("Response body: ${response.body}");
});
if (filePath != null) showInSnackBar('Picture saved to $filePath');
}
});
}
import 'package:async/async.dart';
而不是import 'dart:async';
。还有这个:import 'dart:convert';
。 - Bostrotupload(...)
而不是Upload(...)
。请参见编辑后的帖子。 - Bostrot