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

Add asBase64 option in dhis2 get() function #939

Merged
merged 9 commits into from
Jan 28, 2025
Merged

Conversation

mtuchi
Copy link
Collaborator

@mtuchi mtuchi commented Jan 24, 2025

Summary

Add asBase64 option in get() function which will convert the responseType option to arraybuffer and when we get the result we convert the result into a base64 encoded string

Fixes #884

Details

  • Update axios.interceptors.response to ignore arraybuffer response type
  • Add asBase64 option in get()
  • Update jsdocs for get() options argument

AI Usage

Please disclose how you've used AI in this work (it's cool, we just want to
know!):

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

You can read more details in our
Responsible AI Policy

Review Checklist

Before merging, the reviewer should check the following items:

  • Does the PR do what it claims to do?
  • If this is a new adaptor, added the adaptor on marketing website ?
  • If this PR includes breaking changes, do we need to update any jobs in
    production? Is it safe to release?
  • Are there any unit tests?
  • Is there a changeset associated with this PR? Should there be? Note that
    dev only changes don't need a changeset.
  • Have you ticked a box under AI Usage?

@mtuchi mtuchi linked an issue Jan 24, 2025 that may be closed by this pull request
@mtuchi mtuchi changed the title 884 dhis2 base64 Add asBase64 option in dhis2 get() function Jan 24, 2025
@mtuchi mtuchi requested a review from josephjclark January 24, 2025 18:16
@mtuchi mtuchi marked this pull request as ready for review January 24, 2025 18:16
...requestConfig,
}).then(result => {
console.log(`Retrieved ${resolvedResourceType}`);
return handleResponse(result, state, callback);
const response = asBase64 ? { data: encode(result.data) } : result;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sent me on a bit of a rabbit hole. I think it will be really healthy to rebsae dhis2 on unidic and make it much more standardised

Copy link
Collaborator

@josephjclark josephjclark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mtuchi this looks fine but I haven't tested it. Are you happy for me to release?

@mtuchi
Copy link
Collaborator Author

mtuchi commented Jan 28, 2025

@josephjclark yeah i am happy for release

@josephjclark josephjclark merged commit f594f98 into main Jan 28, 2025
2 checks passed
@josephjclark josephjclark deleted the 884-dhis2-base64 branch January 28, 2025 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

dhis2: allow to download an image binary as a base64 string
2 participants