ckan / ckanapi

A command line interface and Python module for accessing the CKAN Action API
Other
178 stars 74 forks source link

How to add to datastore a resource added via URL? #154

Closed aborruso closed 4 years ago

aborruso commented 4 years ago

Hi, my goal is to update a resource mapped as zip, and change it to CSV (it’s a zip that contains a CSV). This zip file has been added via GUI, not via upload, but adding simply it's URL

Then I have this sort of starting point:

{
"cache_last_updated": null,
"distribution_format": "ZIP",
"id": "3ebcc1f8-0b6b-4599-8de0-d898b9df2835",
"size": null,
"state": "active",
"format": "ZIP",
"mimetype_inner": null,
"url_type": null,
"mimetype": null,
"cache_url": null,
"url": "https://mywebsite.com/my.zip",
}

If I start from an uploaded zipped file, and run these steps

# create the datastore
http --json POST http://mysite.it/api/3/action/datastore_create Authorization:123XXX resource_id=abcXXX force=True
# set the format
http --json POST http://mysite.it/api/3/action/resource_patch Authorization:123XXX id=abcXXX format=csv distribution_format="CSV"

I have automatically (I think there is a predefined trigger inside CKAN) the uncompression of the zip , it is stored in the datastore and I have a tabular preview in the GUI.

But if I start from a zipped resource in which I have set simply an external URL, I do not have uncompression and the storing in the datastore.

What should I further add to the above steps to update my resource and add the unzipping and importing in the datastore?

Thank you

aborruso commented 4 years ago

I'm off-topic