Create or update a CKAN resource.
upload_to_ckan(
data,
resource_title,
dataset_id,
resource_id = NULL,
verbose = get_tsc_verbose()
)
A data frame to write to disk.
A CKAN resource title.
A CKAN dataset (package) ID.
A CKAN resource ID, default: NULL.
Whether to show verbose messages.
Default: get_tsc_verbose
.
The resource ID of the created or updated resource.
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.
Other ckan:
ckan_works()
,
dl_mdbzip()
,
upload_file_to_ckan()
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"
)
}