Closed mjordan closed 4 years ago
The "File Checksum" view allows us to get a SHA1 hash via REST like this:
curl -v -uadmin:islandora "http://localhost:8000/checksum/1"
results in [{"sha1":"39de4231b3885e3d456441c7885fb916f9a94131"}]
.
But it uses File IDs, not UUIDs, which are what are supplied by JSON:API. Maybe we should create our own view that takes the UUID as its parameter?
I've modified the "File Checksum" view (not sure which module creates this view, probably filehash?) to use the file's UUID instead of its ID, and it appears to work. We could have islandora_riprap create its own version of this view on installation.
Started off by creating a View to get a file's hash, but that returned the hash stored in the Drupal database for that file. Instead, added in https://github.com/mjordan/islandora_riprap/issues/33 a controller that uses PHP's hash_file()
function to get the current hash for the file.
Pseudocode for this plugin:
"field_media_image": [
{
"target_id": 3,
"alt": null,
"title": null,
"width": 800,
"height": 1333,
"target_type": "file",
"target_uuid": "e97ad038-dcb3-4d81-aa91-c945b2fe092c",
"url": "http:\\/\\/localhost:8000\\/sites\\/default\\/files\\/2019-03\\/1-Service%20File.jpg"
}
],
(The fieldname of the file, in this case "field_media_image", varies by media type, e.g., field_media_audio
, field_media_document
, field_edited_text
, field_media_file
, field_media_image
, field_media_video_file
.)
Resolved with c740b6140034f95b751e390c5f93063574f0b47e.
Not sure about best source of digests but will investigate and go from there.