Skip to content

@mammadori /

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
How to use CkanClient with CKAN 1.8 for file upload using ckan_client.upload_file(). The fixed issue was about handling HTTP Redirects, the original version returns an "obscure" «('', 'Found')» "warning" instead. The problem was first reported here:
def _post_multipart(self, selector, fields, files):
'''Post fields and files to an http host as multipart/form-data.
:param fields: a sequence of (name, value) tuples for regular form
:param files: a sequence of (name, filename, value) tuples for data to
be uploaded as files
:returns: the server's response page
from urlparse import urljoin, urlparse
content_type, body = self._encode_multipart_formdata(fields, files)
headers = self._auth_headers()
url = urljoin(self.base_location + urlparse(self.base_location).netloc, selector)
req =, data=dict(fields), files={files[0][0]: files[0][1:]}, headers=headers)
return req.status_code, req.error, req.headers, req.text
import ckanclient
# FIXME: no monkey patching here
ckanclient.CkanClient._post_multipart = _post_multipart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.