[ckan-dev] CkanClient file upload

Nigel Babu nigel.babu at okfn.org
Thu Jan 30 06:33:38 UTC 2014


You should urlencode the the file name. Because # as part of a url has a
different meaning: Visit this URL and go to this anchor.

Nigel Babu

Developer  |  @nigelbabu <https://twitter.com/nigelbabu>

The Open Knowledge Foundation <http://okfn.org/>

Empowering through Open Knowledge

http://okfn.org/  |  @okfn <http://twitter.com/OKFN>  |  OKF on
Facebook<https://www.facebook.com/OKFNetwork> |
Blog <http://blog.okfn.org/>  |  Newsletter<http://okfn.org/about/newsletter>

 CKAN | http://ckan.org/ | @CKANproject
<http://twitter.com/CKANproject> |the world’s leading open-source data
portal platform


On 30 January 2014 01:06, Steven Matchett <gosefroba22 at gmail.com> wrote:

> I have implemented a bulk upload using the ckanclient. But have ran into a
> strange issue with file names.  I have had no problems with any files
> except when they contain a '#' character.  When the character is the first
> character of the file name I get this stack trace.
>
> Module ckanext.reviewer.controller:*183* in bulk_upload         <http://localhost:5000/dataset/new_resource/test111#>
>  view <http://localhost:5000/dataset/new_resource/test111#>
> >>   <http://localhost:5000/dataset/new_resource/test111#>data_url = ckan.
> upload_file(file_path)
> Module ckanclient:*663* in upload_file         <http://localhost:5000/dataset/new_resource/test111#>
>  view <http://localhost:5000/dataset/new_resource/test111#>
> >>   <http://localhost:5000/dataset/new_resource/test111#>auth_dict = self
> .storage_auth_get('/form/'+file_key, {})
> Module ckanclient:*530* in storage_auth_get         <http://localhost:5000/dataset/new_resource/test111#>
>  view <http://localhost:5000/dataset/new_resource/test111#>
> >>   <http://localhost:5000/dataset/new_resource/test111#>self.open_url(
> url, payload, headers=headers, method="POST")
> Module ckanclient:*233* in open_url         <http://localhost:5000/dataset/new_resource/test111#>
>  view <http://localhost:5000/dataset/new_resource/test111#>
> >>   <http://localhost:5000/dataset/new_resource/test111#>raise
> CkanApiError(self.last_message)
>
> CkanApiError: Got redirected to another URL, which does not work with
> POSTS. Redirection:
> http://localhost:5000/api/storage/auth/form/2014-01-29T143204/#SaveShenmue-January-2014.png->
> http://localhost:5000/api/storage/auth/form/2014-01-29T143204
>
> And the other error I get is that the file preview becomes broken if a '#'
> symbol is anywhere in the file name.  I mean the easy solution would be to
> strip out any '#', but I would hope to leave that as a last resort
>
> Thank you,,
> Steve
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20140130/a80ba2cd/attachment-0003.html>


More information about the ckan-dev mailing list