Update the ckanext-validation blueprint to include:
An endpoint that accepts an uploaded file or a URL and creates a resource with a file (POST /dataset/<dataset_id>/resource/file). This will be used when in step 1 of creating a new resource (uploading the file). This endpoint will:
Do some data processing and call resource_create with the package_id and the upload / url fields
Return the dataset id, the resource id and the inferred table schema description if present
An endpoint that accepts an uploaded file or a URL and updates the file of resource (POST /dataset/<dataset_id>/resource/<resource_id>/file). This will be used when updating an existing resource. This endpoint will:
Do some data processing and call resource_patch with the resource_id and the upload / url fields
Return the dataset id, the resource id and the inferred table schema description if present
Additional endpoints:
Do we need a custom endpoint for step 2 of creating a new resource (clicking "Save")? The standard resource create endpoint (POST /dataset/<dataset_id>/new) seems to support updating an existing resource if a resource id is provided so that might work out of the box. We just need to make sure client-side that the resource_id is set after getting the response from step 1 (and that the file is not submitted again). That would cover the "Finish" and "Save and Add another" buttons
What happens if a user hits "Previous" or leaves the page after uploading a file? CKAN does not have a concept of "draft resources" so I think we just need to delete the resource:
For the "Previous" rather than overriding the whole core /dataset/resource/new endpoint, I think it will be easier to have a custom endpoint (POST /dataset/<dataset_id>/resource/cancel) that accepts a resource_id (which we'll have if we have uploaded a file) and deletes the resource and the file. If there is no resource_id we just submit the default endpoint.
If the user leaves the page without having clicked on "Finish" we can maybe rely on beforeunload to fire a request to the previous endpoint?
High-level spec: https://github.com/frictionlessdata/ckanext-validation/issues/65#issuecomment-1335093859
Update the ckanext-validation blueprint to include:
An endpoint that accepts an uploaded file or a URL and creates a resource with a file (POST
/dataset/<dataset_id>/resource/file
). This will be used when in step 1 of creating a new resource (uploading the file). This endpoint will:resource_create
with thepackage_id
and theupload
/url
fieldsresource_table_schema_infer
(see https://github.com/frictionlessdata/ckanext-validation/issues/76)An endpoint that accepts an uploaded file or a URL and updates the file of resource (POST
/dataset/<dataset_id>/resource/<resource_id>/file
). This will be used when updating an existing resource. This endpoint will:resource_patch
with theresource_id
and theupload
/url
fieldsresource_table_schema_infer
(see https://github.com/frictionlessdata/ckanext-validation/issues/76)Additional endpoints:
/dataset/<dataset_id>/new
) seems to support updating an existing resource if a resource id is provided so that might work out of the box. We just need to make sure client-side that the resource_id is set after getting the response from step 1 (and that the file is not submitted again). That would cover the "Finish" and "Save and Add another" buttons/dataset/resource/new
endpoint, I think it will be easier to have a custom endpoint (POST/dataset/<dataset_id>/resource/cancel
) that accepts a resource_id (which we'll have if we have uploaded a file) and deletes the resource and the file. If there is no resource_id we just submit the default endpoint.beforeunload
to fire a request to the previous endpoint?