通过CKAN API(1.8)上传文件:怎么做?

时间:2013-02-18 23:52:10

标签: json bash file-upload curl ckan

我正在尝试在CKAN实例中自动化数据集和资源上传。我使用的是64位的Ubuntu Linux 10.04,我的CKAN实例版本是1.8。

我可以使用如下命令创建一个新数据集:

$ curl http://ckan.installation.com/api/rest/dataset -H "Authorization:<my api key>" -d '{"name": "dataset-name", "title": "The Name of the Dataset"}'
{... JSON text recieved in response, including the id of the dataset ...}

现在,如何使用命令行在CKAN实例中创建和上传资源(如图像文件)?

谢谢!

1 个答案:

答案 0 :(得分:2)

通过FileStore API上传文件有点复杂。你最好重用ckanclient's upload_file method。使用它的简单Python脚本可以解决从命令行上传的问题。

或者,如果您感到勇敢,那么这是开始了解如何使用cURL上传文件的最佳位置。