hot to send pdf from appgyver to xano via base64

Options
josephrezende
josephrezende Member
edited February 2023 in AppGyver

Hi, my name is Joseph and im building a app using appgyver as my front-end, i've tried to use an API call to send the pdf path to xano but it says the path is missing even on xano “run & debug”.

The breakedown process is:

On appgyver

1-Get pdf file from internal storage;

2- convert the path to base64

3-send to xano with the formula “data:application/pdf;base64,”+ converted path;

On Xano my table just have 2 informations, file and user_id (reference from my user table)

At my querry workflow i created a attatchment from input file to a var called “pdf” then on "create record" the file to store comes from the var “pdf”

I dont know what im doing wrong, i did the same metod to send images and worked perfectly but pdf for some mysteriously reason (at least for me) it does not work

Tagged:

Answers

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    edited February 2023
    Options

    You probably want to split out the base64 data from your data URI and then decode it.

    One way to do this in the xano function stack:

    1. Create a variable split the string on a comma (,) and then take the last of that set (e.g. pop)
    2. Update that variable to itself with a base64_decode filter.
    3. Make a file resource from data using the result from (2)
    4. Make the metadata (likely attachment) to save the file to Xano and generate the data you can add to your database record.

    Working with files can be complicated. We work with the hardest 5% of no-code projects in our daily office hours on State Change Pro (https://statechange.ai).

  • josephrezende
    Options

    Hello Ray, thanks for the response,

    I've been able to make it work, i changed the type “attachment” to "file resource" on the query workflow and it worked via “run & debug” and via “Data configurator" on appgyver, but for some reason when i run the app preview and try again, it gives me a “Failed to execute”, i'm still trying to figure out what im missing.

    But anyways thanks for the response and clarification!!

  • josephrezende
    Options

    Well, i've figured out.

    When converting pdf to base64 the logic flow was adding “data:application/pdf;base64” already, but i didnt know, so i was adding it again, that's why i was receiving a JSON error response. After removing the addicional URI it worked perfectly!!