Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use python-requests to upload file #33

Merged
merged 2 commits into from
Jan 9, 2014
Merged

Use python-requests to upload file #33

merged 2 commits into from
Jan 9, 2014

Conversation

Hoedic
Copy link
Contributor

@Hoedic Hoedic commented Dec 28, 2013

Use python-requests (instead of pycurl) to upload file to CKAN.

@rufuspollock
Copy link
Member

@davidread are you happy to review this?

@davidread
Copy link
Contributor

Thanks Hoedic!!

In testing this with both datahub.io and demo.ckan.org, I get an error back from Google Storage - see below. I've no idea whether this is a problem with the client or whether CKAN is pointing the client at storage which is not configured.

>>> import ckanclient
>>> ckan = ckanclient.CkanClient(base_location='http://datahub.io/api', api_key='<key>')
>>> ckan.upload_file('/vagrant/test.csv')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/vagrant/ckanclient/ckanclient/__init__.py", line 582, in upload_file
    raise CkanApiError(body)
ckanclient.CkanApiError: <?xml version='1.0' encoding='UTF-8'?><Error><Code>InvalidArgument</Code><Message>Invalid argument.</Message><Details>Cannot create buckets using a POST.</Details></Error>

@Hoedic which server did you test on? @rgrp do you know about this Google Storage error?

I've put the merged version that I tested on the branch: okfn/pull-33-requests

@Hoedic
Copy link
Contributor Author

Hoedic commented Jan 7, 2014

Hey @davidread ,

I tested on CKAN 2.1 with a local storage. the error message sounds like a google storage issue but this is rather strange.

Did you try to upload the file using the last commit before I start playing with Ckanclient?

@rufuspollock
Copy link
Member

@Hoedic I think there were perhaps some issues earlier with the upload - see #34 Right now I think we merge this and then fix in master and then release :-)

@davidread davidread merged commit c45664d into okfn:master Jan 9, 2014
@davidread
Copy link
Contributor

@Hoedic good idea to try the old version. I tried 183ad05 (June 2012) and it works fine:

>>> ckan.upload_file('/vagrant/test.csv')
(u'https://ckannet-storage.commondatastorage.googleapis.com/2014-01-09T143728/test.csv', '')

so the storage is working fine. However your code using requests still suffers the same error about creating a bucket with a POST. I also managed to test the current master using pycurl and it too has the same problem.

Since it is no worse than master, I'm going to merge it and raise an issue, which I'd be pleased if you were able to look at. I think this needs sorting before we release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants