AaronV77
AaronV77

Reputation: 119

Uploading File to CKAN

I'm trying to upload a basic file to the demo.ckan.org site with the python ckanapi. Below is what I tried doing:

from ckanapi import RemoteCKAN
api_key = "an_api_key"
demo = RemoteCKAN(address='https://demo.ckan.org', apikey=api_key)

dataset_dict = {"name": dataset_name, "title": dataset_title, "private": False, "author": "Aaron", "author_email": "[email protected]", "maintainer": "Aaron", "license_id": "None", "notes": "nothing to explain", "version": "version-1", "state": "active", "type": "generic"}

my_package = demo.action.package_create(context=my_context, **dataset_dict)
pprint(my_package)

resource1 = {"package_id": my_package["id"], "description": "conda env file", "format": "python", "name": "Python2 Conda Env File", "resource_type": "Generic", "created": "2018-03-27", "last_modified": "2018-03-27", "cache_last_updated": "2018-03-27", "upload": "/Users/aaron/Documents/Quest/quest/py2_conda_environment.yml"}

demo.action.resource_create(**resource1)

Results:
{'cache_last_updated': '2018-03-27T00:00:00',
 'cache_url': None,
 'mimetype_inner': None,
 'hash': '',
 'description': 'conda env file',
 'format': 'python',
 'url': '',
 'created': '2018-03-27T00:00:00',
 'state': 'active',
 'package_id': 'my_package_id',
 'last_modified': '2018-03-27T00:00:00',
 'mimetype': None,
 'url_type': None,
 'position': 0,
 'revision_id': 'my_revision_id',
 'size': None,
 'datastore_active': True,
 'id': 'resource_id',
 'resource_type': 'Generic',
 'name': 'Python2 Conda Env File'}

So when I get done doing the previous code and go onto the demo site and log into my account to view the resources. All I see is the metadata and no file? Even in the results I got back from the demo.action.reesource_create() function I do not see anything about an upload of any nature. Is there anything that I am currently doing wrong? Thanks.

Upvotes: 0

Views: 395

Answers (1)

tino097
tino097

Reputation: 414

I think there is an issue with uploads using ckanapi https://github.com/ckan/ckanapi/issues/128

Upvotes: 2

Related Questions