image_to_base64(){
if [ -f $1 ]; then
IMAGE=`base64 $1`
fi
}
curl -s -k "https://aip.baidubce.com/rest/2.0/face/v3/detect?access_token=$ACCESS_TOKEN" --data '{"image":"'$IMAGE'","image_type":"BASE64","face_field":"age,beauty,expression,faceshape,gender,glasses,landmark,race,quality,facetype"}' -H 'Content-Type:application/json; charset=UTF-8'
我传入一个文件名是jpg格式。转换之后存在IMAGE变量里,然后curl一直返回{"error_code":222001,"error_msg":"param[image] is null","log_id":9420194001792,"timestamp":1531219343,"cached":0,"result":null}
收藏
点赞
0
个赞
请登录后评论
TOP
切换版块
解决了,具体的原因不太清楚,自己把base64编码后的数据再进行urlencode之后就可以了。用curl自带的不行。
{"error_code":222001,"error_msg":"param[image] is null","log_id":7989797545250,"timestamp":1531219736,"cached":0,"result":null}curl: (6) Could not resolve host: FhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj; Name or service not known
curl: (6) Could not resolve host: KCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj; Name or service not known
执行后会卡住,然后打印这个,是不是请求的时候image字段里的内容有问题啊?