Create or update a CKAN resource.

upload_to_ckan(
  data,
  resource_title,
  dataset_id,
  resource_id = NULL,
  verbose = get_tsc_verbose()
)

Arguments

data

A data frame to write to disk.

resource_title

A CKAN resource title.

dataset_id

A CKAN dataset (package) ID.

resource_id

A CKAN resource ID, default: NULL.

verbose

Whether to show verbose messages. Default: get_tsc_verbose.

Value

The resource ID of the created or updated resource.

Details

The data will be written to CSV in a directory data/ with the resource title in snake_case. If no resource ID is given, a resource will be created. The resource ID is returned in either case.

See also

Examples

if (FALSE) {
ckanr::ckanr_setup(
  url = Sys.getenv("CKAN_URL"), key = Sys.getenv("CKAN_API_KEY")
)
d <- ckanr::package_show("threatened-ecological-communities-database")

# Run this once to create resource and retrieve resource ID
upload_to_ckan(a_tibble, "Resource title", d$id, resource_id = NULL)
# returns "502c74d7-32be-453f-aff6-c50aedd3deed" - paste into resource_id

# Re-run this to update resource with new data
upload_to_ckan(a_tibble, "Resource title", d$id,
  resource_id = "502c74d7-32be-453f-aff6-c50aedd3deed"
)
}