In CKAN when creating an organization with the web interface, it's possible to provide an image_url or select a image on our local disk. With this 2nd choice, the image is uploaded and the organisation has the link to the image.
With the CKAN API there is only a parameter image_url
, and I can't find a solution to upload an image with the API.
How can I upload an image to provide the image_url
paramater to the API ?
I tried to look for the API, but I only found resource API that is not adapted for this need. And I found nothing in the doc or forums.
I answer to my question:
myorg
without image (necessary for the step 2)curl --location --request POST 'http://localhost:5001/api/3/action/package_create' \
--form 'name="myds"' \
--form 'owner_org="myorg"'
curl --location --request POST 'http://localhost:5001/api/3/action/resource_create' \
--form 'package_id="myds"' \
--form 'upload=@"./myimage.jpg"' \
--form 'name="myimage.jpg"'
Retrieve the URL from the response
You now have an URL for the resource, and you can use it to update the organisation or create a new one.