"This resource is not a valid image" when trying to store an image from a base64 string.
Hi Xano-ers, I'm having trouble trying to store an image from a 3rd party API that comes through as a base64 string, and I'm not quite sure what I'm doing wrong.
Here's what I'm currently doing—
I first use the "Create file resource" function with file name as "newFile.png" and file data as a variable of the base64 string for the image
This step returns a funky string that looks like this.
After this step, I use the "Create image from file" function using the returned value from the screenshot above. This is where I run into problems—I keep getting a "This resource is not a valid image." message from Xano.
Any idea what might be the problem?
Comments
-
Hey Wes, I suspect the value is still base64 encoded at that point. First pass idea: create a new variable (image decodes?) with the value of the image with the filter base64_decode run on it before you make the file resource.
-
@Ray Deck Great suggestion—that worked! Thank you.
For whoever else runs into this in the future(or for improving the Xano docs CC @Michael Udinski): the docs mention that the file resource input can handle a base64 encoded file, but there isn't clarity on what the "create a file resource" function can handle. From this, it seems it does not handle base64 encoded files—you have to decode them first like Ray suggested.
-
Hey Wes, thanks for the heads up on this! We've made sure to update our documentation to reflect this difference and will look at improving this in the future.
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback