Skip to content

Fix two small bugs with the RestAPI Datasource #798

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

Merged

Conversation

snowe2010
Copy link
Contributor

@snowe2010 snowe2010 commented Apr 6, 2024

Proposed Changes

First bug:

Spring automatically transforms binary content to base64, therefore the
logic in the RestApiExecutor was causing the data to be encoded twice,
causing much confusion and frustration for several weeks actually.

Second bug:

the fileUtils#saveDataAsFile function was not actually setting the type
correctly when attempting to convert the base64 data to a binary blob,
thus the files would always download as a 'dms' file and it would
never actually be openable. This also caused a lot of confusion. Both of
these bugs together made it impossible to tell why stuff was broken.

Combined this means that anytime you were trying to download binary data
you would never actually be able to open the file, as it would be only
base64 data inside of it.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Checklist

  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Further comments

I tested by creating a repo with a test release and an xlsx file in it. https://github.com/snowe2010/test-release-downloads/releases/tag/v1

I then wrote a small app with two queries, one to retrieve asset from github, the other to download the asset to my computer.
image
image

I tested both with and without my change to each file. Both are necessary to get the file download working.

First bug:

Spring automatically transforms binary content to base64, therefore the
logic in the RestApiExecutor was causing the data to be encoded twice,
causing much confusion and frustration for several weeks actually.

Second bug:

the fileUtils#saveDataAsFile function was not actually setting the type
correctly when attempting to convert the base64 data to a binary blob,
thus the files would _always_ download as a 'dms' file and it would
never actually be openable. This also caused a lot of confusion. Both of
these bugs together made it impossible to tell why stuff was broken.

Combined this means that anytime you were trying to download binary data
you would never actually be able to open the file, as it would be only
base64 data inside of it.
Copy link

netlify bot commented Apr 6, 2024

👷 Deploy request for lowcoder-test pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 64293b9

Copy link
Contributor

@FalkWolsky FalkWolsky left a comment

Choose a reason for hiding this comment

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

Thank you very much for this valuable contribution and bug fix!
This will help surely a lot of Lowcoders!

@FalkWolsky FalkWolsky merged commit 2c9cd17 into lowcoder-org:dev Apr 8, 2024
3 checks passed
@snowe2010 snowe2010 deleted the fix-rest-api-base64-handling-dev branch April 8, 2024 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants