将python请求转换为http颤振
我的python代码如下:将python请求转换为http颤振,python,flutter,http,python-requests,Python,Flutter,Http,Python Requests,我的python代码如下: 文件={ “图像url:(无,”), “图像内容”:(无、), “文件名”:(无,”, “h1”:(无,“en”), “波黑”:(无,'179'), “白车身”:(无,“1600”), “编码图像”:(无,打开(文件,'rb'), } response=requests.post('https://www.google.co.in/searchbyimage/upload,files=files,allow_redirects=True) curl命令是 curl-
文件={
“图像url:(无,”),
“图像内容”:(无、),
“文件名”:(无,”,
“h1”:(无,“en”),
“波黑”:(无,'179'),
“白车身”:(无,“1600”),
“编码图像”:(无,打开(文件,'rb'),
}
response=requests.post('https://www.google.co.in/searchbyimage/upload,files=files,allow_redirects=True)
curl命令是curl-F encoded_image=@/path/to/image.jpghttps://www.google.de/searchbyimage/upload
如何将此代码转换为Flatter HTTP或任何其他包(如dio)?导入
dio
包
Future<String> uploadFile(File file) async {
String fileName = file.path.split('/').last;
FormData formData = FormData.fromMap({
// your other data here
"file":
await MultipartFile.fromFile(file.path, filename:fileName),
});
response = await dio.post("https://www.google.co.in/searchbyimage/upload", data: formData);
return response.data;
}
Future uploadFile(文件文件)异步{
字符串文件名=file.path.split(“/”).last;
FormData FormData=FormData.fromMap({
//你的其他数据在这里
“文件”:
等待MultipartFile.fromFile(file.path,filename:filename),
});
响应=等待dio.post(“https://www.google.co.in/searchbyimage/upload“,数据:formData);
返回响应数据;
}
非常感谢