Skip to content
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

Create a FetchDigestFromDrupal plugin #44

Closed
mjordan opened this issue Apr 3, 2019 · 5 comments
Closed

Create a FetchDigestFromDrupal plugin #44

mjordan opened this issue Apr 3, 2019 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@mjordan
Copy link
Owner

mjordan commented Apr 3, 2019

Not sure about best source of digests but will investigate and go from there.

@mjordan mjordan added the enhancement New feature or request label Apr 3, 2019
@mjordan mjordan self-assigned this Apr 3, 2019
@mjordan
Copy link
Owner Author

mjordan commented Apr 11, 2019

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?

@mjordan
Copy link
Owner Author

mjordan commented Apr 12, 2019

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.

@mjordan
Copy link
Owner Author

mjordan commented Aug 19, 2020

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 mjordan/islandora_riprap#33 a controller that uses PHP's hash_file() function to get the current hash for the file.

mjordan added a commit that referenced this issue Aug 19, 2020
@mjordan
Copy link
Owner Author

mjordan commented Aug 19, 2020

Pseudocode for this plugin:

  1. The "Riprap resource list" View created by Islandora Riprap give us media IDs that are tagged with "Original File" (configurable)
  2. With that ID, the plugin will need to do a REST request for the media ID, which provides the media's file in the form
  "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.)

  1. From this JSON, the plugin can get the file's URL and UUID.
  2. With the UUID, the plugin can then get the hash using the controller added in Add a controller to get a file's hash islandora_riprap#33.

mjordan added a commit that referenced this issue Aug 24, 2020
mjordan added a commit that referenced this issue Aug 26, 2020
mjordan added a commit that referenced this issue Aug 30, 2020
mjordan added a commit that referenced this issue Aug 30, 2020
@mjordan
Copy link
Owner Author

mjordan commented Aug 30, 2020

Resolved with c740b61.

@mjordan mjordan closed this as completed Aug 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant