You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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
The text was updated successfully, but these errors were encountered:
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 likeasBase64
, 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 attributeEquipment Image
) that you can test downloading: https://lmis.integration.dhis2.org/sandbox/dhis-web-tracker-capture/index.html#/dashboard?tei=qHVDKszQmdx&program=GqijeO4NM3E&ou=FV43JisquSmYou can try to get this^ record by sending a GET request for TEI
qHVDKszQmdx
. In the response, search for the Attribute ID forEquipement image
:BqaEWTBG3RB
The text was updated successfully, but these errors were encountered: