[ckan-discuss] Uploading resources using CkanClient

Adi Eyal adi at burgercom.co.za
Fri Aug 31 23:25:21 BST 2012


Hi All

I'm struggling to upload files using CkanClient.

Here is my code

import ckanclient
import sys


key = "...."

ckan = ckanclient.CkanClient(api_key=key,
base_location="http://data.codingfordemocracy.org/api")

f = sys.argv[1]
ckan.add_package_resource("census-2001", f, resource_type="data")


I get the following error:

Traceback (most recent call last):
  File "upload.py", line 18, in <module>
    ckan.add_package_resource("census-2001", f, resource_type="data")
  File "/usr/local/lib/python2.7/dist-packages/ckanclient/__init__.py",
line 724, in add_package_resource
    return self.package_entity_put(p)
  File "/usr/local/lib/python2.7/dist-packages/ckanclient/__init__.py",
line 299, in package_entity_put
    self.open_url(url, data, headers, method='PUT')
  File "/usr/local/lib/python2.7/dist-packages/ckanclient/__init__.py",
line 231, in open_url
    raise CkanApiConflictError(self.last_status)
ckanclient.CkanApiConflictError: 409

I also see this suspicious message in my apache logs:

IOError: failed to write data but it doesn't give me any context.

I've check that www-data has write access to my filestore directory as
well as pretty much the entire ckan folder.

Any suggestions on where else to look?

Thanks in advance
Adi


-- 
Adi Eyal



More information about the ckan-discuss mailing list