我想上传在 swift 应用程序中捕获的图像,因此图像作为对象我需要通过 http 请求来执行此操作 首先,我尝试使用curl来做到这一点,但我收到一个错误,即字符串太长,第二次我尝试使用网站中发布的示例代码,但它不起作用
来自网站的代码示例:
curl -X POST
-H 'Authorization: Key YOUR_API_KEY'
-H "Content-Type: application/json"
-d '
{
"inputs": [
{
"data": {
"image": {
"url": "https://samples.clarifai.com/demographics.jpg"
}
}
}
]
}'
https://api.clarifai.com/v2/models/c0c0ac362b03416da06ab3fa36fb58e3/outputs
我想将图像上传为快速捕获的 UIImage 对象,而不是 URL
最佳答案
尝试以下curl
命令:
curl -X POST \
-H "Authorization: Key YOUR_API_KEY" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d '{"inputs":[{"data":{"image":{"url":"https://samples.clarifai.com/demographics.jpg"}}}]}' \
https://api.clarifai.com/v2/models/c0c0ac362b03416da06ab3fa36fb58e3/outputs
这似乎对我有用。
关于swift - 发布图像对象 Clarifai Rest api swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56321643/