Let me help you with the implementation for multiple images.
We can set uploadFile
as if we already had the data, just define the variables that we'll replace using additionalScope
:
For the JS, we need:
- Iterate over the value of the Image input component.
- Get the base64 data of each image.
- Trigger
uploadFile
passing the right data and name for each file.
Here is the JS:
let images = imageInput1.value
for(let i = 0; i < images.length; i ++){
let base64Image = await utils.getDataByObjectURL(images[i])
let encoded = base64Image.split(", ")[0]
await uploadFile.trigger({
additionalScope: {
formattedfile: encoded,
fileName: textInput1.value + "-" + i
}
})
}
The app needs the Image & Text input components, and a button to trigger the JS query:
That should work like a charm: