jonmsawyer
jonmsawyer

Reputation: 58

Uploading a file through CKAN's API (1.8): How to do it?

I am trying to automate dataset and resource uploading in my CKAN instance. I am using Ubuntu Linux 10.04 64-bit and my CKAN instance version is 1.8.

I can create a new dataset using the command like like so:

$ 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 ...}

Now, how do I go about creating and uploading resources (like image files) in my CKAN instance using the command line?

Thanks!

Upvotes: 1

Views: 1282

Answers (1)

Vitor Baptista
Vitor Baptista

Reputation: 2096

Uploading a file through the FileStore API is somewhat complicated. You'll be better reusing ckanclient's upload_file method. A simple Python script that uses this could solve your problem of uploading from the command-line.

Or, if you're feeling brave, that's the best place to start understanding how to upload a file using cURL.

Upvotes: 2

Related Questions