How to handle "List of files" from external API?

Hello,

I have a data type with a field “List of files” that I use to allow user to upload files from my bubble app. This app is connected to a Ruby on Rails external app through webhooks.

What I’m trying to do is to send files from my Ruby on Rails app to populate this “List of files”. I don’t really know how to send those files to Bubble. I tried with an array of URLs but it doesn’t seem to work. Ex : [“https://image1.jpg”, “https://image2.jpg”]

Do you know how I could handle that? “List of texts” could be a solution?

Thanks a lot for your help!

Yea if the files already have a URL then saving as a list of texts will work. There are other solutions for if they are files and they do not have urls.

I use a node.js package to create pdf files and this is how they are uploaded.

const pdfDataUri = await pdfDoc.saveAsBase64({ dataUri: true });
const file = {
       "filename": customerData.lastName + '.pdf',
       "contents": pdfDataUri.startsWith('data:application/pdf;base64,') ? pdfDataUri.split(',')[1] : pdfDataUri,
       "private": false,
       "attach_to": null
};
const uri = url.startsWith('http') ? url : 'https:' + url;
const body = { "file": file };
let bubble = await axios.post(`${uri}api/1.1/wf/upload_pdf`, body, axiosOptions)
let fullDocUrl = bubble.data.response.url.startsWith('http') ? url : 'https:' + bubble.data.response.url;
return fullDocUrl //here is your new url provided by Bubble s3

Screenshot 2023-04-14 at 9.28.20 AM
Screenshot 2023-04-14 at 9.28.33 AM

1 Like

Thank you William!

I will have a look on your solution and try to adapt it to my app :slight_smile: