Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将python请求转换为http颤振_Python_Flutter_Http_Python Requests - Fatal编程技术网

将python请求转换为http颤振

将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-

我的python代码如下:

文件={
“图像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);
返回响应数据;
}

非常感谢