Upload Data stream to Xano

Hi,

I am working on a feature where you can modify or upload a new template.
Uploading a new template is straightforward and documented well in WeWeb, but programmatically uploading a data stream to Xano is not working, here is what I am doing:

I am getting a base64 binary stream of a docx file returned from a Xano Request and now I need to upload it to a different Xano Endpoint, but I am not able to get it to work, I’m able to download the file/binary stream locally easily but I’m not able to programmatically add it to the request and upload it,

I am getting this error:

stack: "Error: Request failed with status code 400 at e.exports (https://editor-cdn.weweb.io/public/js/chunk-vendors.7f825e18.js:1:103697)…

Hi @eduardJ,

Does this section about file uploads directly to the backend help by any chance?

I’m thinking maybe not since you’re already managing to upload new templates to Xano :confused:

If not, could you share a short video of how things are setup in your WeWeb project and Xano workspace and showing us where you’re stuck?

It’ll help me understand the whole flow and hopefully find a solution for you!

Hy @Joyce thnx for the reply,

I tried that section but it didn’t help, I found a way of uploading the document via a custom js function which makes an xhr request, which is exactly what the Xano request should have been doing all along but whenever I try passing the same object to the Xano request all I get is:

Request failed with status code 400

It seems that whenever here is my payload:

{
    "title": "test name",
    "clientId": 999,
    "description": "asdasd",
    "file_resource": {}
}

as you can see the file resource is an empty object even though I get this object from this action:

image

If there is a way to make this custom javascript function asynchronous and return a result that would solve my issue.

Here is another image I’m not able to upload more than one since am a new user:

Alright. I don’t have a lot of experience with this use case. Let me ask someone on the tech team if they can help :slight_smile:

Alright! The team says it should work if you build the data url yourself, something like this data:app/vnd.blabla;base64,<thebase64string>

Does that help?

Hey @Joyce ,

We went with a different solution moving the logic to Xano completely (download and upload of the document), this solved our issues.

Thanks for your reply.