PUT request file upload

Hey,

could anyone help me with uploading a file through a PUT request to my S3-compatible storage please? So I’m using a file uploading element, and tried binding the element’s value-variable into my API request. However not really sure what goes where, I tried adding a “content”-key and as a value the binding to the file object. This doesn’t work. There is a record created in my S3, but it’s corrupted and missing the content, i.e. the file itself and just few bytes in size. Also tried several variations, but wasn’t successful.

Thanks!

and here the screencap of the binding, ‘myfile’ is the file upload element

1 Like

@Sebastian_M Welcome to the community.

Are you uploading the file in the previous workflow action?

WeWeb (currently**) uploads the file to their CDN with a workflow action.

**I believe that WeWeb is working on updating the element so that you can just store the file into your database directly, but right now it goes into the WeWeb CDN first.

If you want to store the file in the S3 Storage, you are going to need to use the workflow action to upload the file to WeWeb CDN, and then get it into S3.

The result of the upload action contains the URL of the file.

I’m not familiar with S3, but do they have an endpoint that you can supply a URL to that will then take the file and bring it into S3?

If so, that would be something you could just do on the next workflow action.

If I’m understanding your question correctly, I think the above will work. And, checkout these links on the upload element:

Is that helpful?

2 Likes

Hi Kevin,

thanks a lot! So I’m not uploading the pdf to WeWeb, but only using the file upload element to pick the pdf (it creates a file object). I want to use this file object and upload directly to my S3 endpoint. I know it’s there but don’t really know how to properly place it into in a “API-request”-workflow. The same request does work with Postman, however with Postman I just select the file of course.

It does work though when following the tutorial under ⬆️ File Upload, using a custom JS workflow including creating a new formData and using axios.put for uploading. However the issue I’m lacking JS knowledge and it keeps on breaking when adding additional headers to my request, see screenshots

It does work with just the content type header, but I need the additional header X-Amz-Acl (for setting S3 permissions)

One way or the other, API request workflow or custom JS workflow, I’d be happy if someone can help, thanks!

It does work fine with just the content-type header, and the file is properly uploaded into my bucket

As mentioned in my first post, if I use the other option, API request workflow, it does create a file in my bucket as well, however it’s missing the content (the file object) itself and it’s just a few bytes in size.

The issue with using axios.put was related to a CORS error. Fixed it, uploads are working and I’m fine for now, thanks

2 Likes

I’m not very knowledgeable about JS. I got through the first step, but when trying to create a record in my back end (Xano), I ran into this error: “Missing param: type”. I am trying to upload a word doc through Xano’s “Upload an Attachment” end point.

My next question is going to be about uploading multiple files at one time directly to Xano, so if anyone has an answer for that, it’d be much appreciated!

It sounds like you are missing a required input named “type” when you run it.

Lastly, we have a tutorial on uploading multiple files at once through the Xano API:

3 Likes

If you find this later, and need multiple upload, here is a post with the information and script:

1 Like