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

dhis2: allow to download an image binary as a base64 string #884

Open
josephjclark opened this issue Jan 8, 2025 · 0 comments · May be fixed by #939
Open

dhis2: allow to download an image binary as a base64 string #884

josephjclark opened this issue Jan 8, 2025 · 0 comments · May be fixed by #939
Assignees

Comments

@josephjclark
Copy link
Collaborator

josephjclark commented Jan 8, 2025

We have a requirement for the Ghana national ID project to upload an image as a base64 string.

The image in question will come from DHIS2 and be returned as a binary steam.

We need to extend the dhis2 adaptor so that we can convert a binary stream into a base64 string.

I think this means an option on the get helper, something like asBase64, which would take whatever response we get from dhis2 and convert it into a base64 string.

Note that this will return the whole string, not a stream.

A complication on large images and payloads

In order to pass the image onto the next step (ie, to be uploaded in to the NID generator), we have to write the string to the state object and send it back lightning as the output for the step. It could be a big image and could blow memory limits for worker-lightning payloads.

Two possible solutions to this are:
a) work out some way to pass a stream directly between steps (meaning the stream does not get sent back to lightning and the step is not repeatable)
b) download the image from dhis2 straight into the National ID step using a vanilla HTTP helper (in which case this is not a dhis2 issue)

In both approaches, basically we pass the unprocessed binary stream from dhis2 straight into the NID step, then base64 encode on the fly and pass the encoded stream straight into the request (a stream pipeline -I think this is possible but I don't actually know a lot about the base64 encoding process - can we encode on the fly in chunks? Surely yes?)

Saying all that I think that serializing the image to a string on state is feasible and appropriate

Credentials

Play DHIS2 instance: https://lmis.integration.dhis2.org/sandbox/
Web User: demo Password: Stock123!

Testing Guidance

If you log in via the web UI and go to this trackedEntityInstance, you will find that it has an image (see TEI attribute Equipment Image) that you can test downloading: https://lmis.integration.dhis2.org/sandbox/dhis-web-tracker-capture/index.html#/dashboard?tei=qHVDKszQmdx&program=GqijeO4NM3E&ou=FV43JisquSm

You can try to get this^ record by sending a GET request for TEI qHVDKszQmdx. In the response, search for the Attribute ID for Equipement image: BqaEWTBG3RB

Screenshot 2025-01-19 at 11.41.22 PM.png

@github-project-automation github-project-automation bot moved this to New Issues in v2 Jan 8, 2025
@mtuchi mtuchi linked a pull request Jan 24, 2025 that will close this issue
13 tasks
@mtuchi mtuchi linked a pull request Jan 24, 2025 that will close this issue
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New Issues
Development

Successfully merging a pull request may close this issue.

3 participants