swift - 发布图像对象 Clarifai rest api swift
问题描述
我想上传在 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
它似乎对我有用。
推荐阅读
- javafx - 创建特定类型的组
- python - 停止芹菜工人处理任务或监控 Flower 中的“未使用”任务
- angular - 从Angular 2+中的父组件将样式应用于动态加载的组件
- c - 在 C/C++ 宏中的 __VA_ARGS__ 上的迭代中添加分隔符
- node.js - 如何使用表单将值发送到 JS 文件并执行 NodeJS
- c# - 将 SQL 中的参数替换为外键
- regex - Kotlin getValue for String 包含单词/ s 忽略大小写和空格
- php - laravel,如何重定向到最佳 URL
- rest - 在 WEB API 请求中提供对嵌套资源的直接访问而不指定父级?
- node.js - 将文件共享复制到另一个文件共享 Node.js