-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Workbench use Drupal's built in REST interfaces for files and media #171
Comments
Probably wait until Islandora ships with Drupal 9.1 to implement this, since creating media via REST suffered from https://www.drupal.org/project/drupal/issues/3072076. After that is fixed, the following should work:
then PATCH with field data like:
|
OK, back in business. In Drupal 9.2.0-dev, the issue linked above is resolved. This now works for creating file: curl -v -X POST -uadmin:islandora -H'Accept: application/vnd.api+json' -H'Content-Type: application/octet-stream' -H'Content-Disposition: file; filename="test.jpg"' --data-binary @test.jpg "http://localhost:8000/jsonapi/media/image/field_media_image" Then, for creating the file's media: curl -v -X POST -uadmin:islandora -H'Accept: application/vnd.api+json' -H'Content-type: application/vnd.api+json' --data @media.json "http://localhost:8000/jsonapi/media/image" with the following as the {
"data":{
"type":"media--image",
"attributes":{
"name":"My media"
},
"relationships":{
"field_media_of":{
"data":{
"type":"node--islandora_object",
"id":"fa12d7ce-f66c-494f-b149-d95c3c201210" // 'type' and 'id' are available in the node HTTP response.
}
},
"field_media_image":{
"data":{
"type":"file--file",
"id":"5060c33a-789f-4850-a2f9-2f6e05e2dd65" // 'type' and 'id' are available in the file HTTP response.
}
},
"field_media_use":{
"data":{
"type":"taxonomy_term--islandora_media_use",
"id":"cc5e6f00-be2f-4d07-b047-be39cd9b7387"
}
}
}
}
} |
Some preliminary tasks: First, to create files, Workbench will need a media type -> media field mapping like this:
and this will need to be extensible via configuration, to accommodate custom media types. Second, to create media, we'll need to be able to get UUIDs for instances of nodes, files, and taxo terms, as illustrated abobe. |
To do: validate that the media bundle has the indicated field. |
|
#254 adds code to check version of Drupal core. Depends on islandora_workbench_integration commit 638d172b2589463c36b2032c6400f62063fc932d. Note to self: to put this into production, uncomment |
…ndency on JSON:API; added install configuration for File Upload REST endpoint.
Noteworthy changes to Workbench resulting from development on this issue:
|
Merged into main with b37f353. |
... instead of using Islandora's MediaSourceController. As discussed at the 2020-12-09 Islandora 8 Tech call re. Islandora/documentation#1481, this controller provides a lot of Islandora-specific plumbing that it would be disruptive and difficult to refactor. It is likely to be an order of magnitude simpler to adapt Workbench's
create_media()
function to use Drupal's File and Media REST resources to attach a file and then a media to a node.The text was updated successfully, but these errors were encountered: