Error when importing multiple files to external bucket

  • Goal: I'm trying to import multiple files using the file input component

  • Steps:

  1. Use the file input component
  2. for each file I base64 decode the string
  3. I pass the result to a custom api call to my storage
  4. got the error: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
function base64ToArrayBuffer(base64) {
    const binaryString = atob(base64);

    const length = binaryString.length;
    const bytes = new Uint8Array(length);

    for (let i = 0; i < length; i++) {
        bytes[i] = binaryString.charCodeAt(i);
    }

    return bytes.buffer;
}


async function go() {
  for (let i = 0; i < input_import_files.value.length; i++) {
    const base64Data = input_import_files.value[0].base64Data
    const decodedData = base64ToArrayBuffer(base64Data)
    input_import_files.value[0]
    const fileName = input_import_files.value[0].name
    await import_to_bucket.trigger({additionalScope: { fileName, data: decodedData}})
  }
}
return go()


I am not sure if it was ever fixed, but I do not that some time ago, I was running into issues with excel spread sheets being uploaded as causing some issues. Sorry I cannot help out more.

Hi @Lior_Rok,

I believe the issue is that retool's Form Data is not working as expected, and you can choose another format to upload your data. Try setting it to JSON and let me know if that works for you. If not, could you send me the complete url for your api so I can test on my end?