将文件上传到CKAN

时间:2018-04-12 15:46:53

标签: ckan

我尝试使用python ckanapi将基本文件上传到demo.ckan.org网站。以下是我尝试做的事情:

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": "none_of_your_buisness@.com", "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'}

因此,当我完成上述代码并进入演示站点并登录我的帐户以查看资源时。我看到的只是元数据而没有文件?即使在我从demo.action.reesource_create()函数返回的结果中,我也没有看到任何关于任何性质的上传的内容。有什么我目前做错了吗?感谢。

1 个答案:

答案 0 :(得分:2)

我认为上传使用ckanapi存在问题 https://github.com/ckan/ckanapi/issues/128