Google Drive Multi File Upload Help

Im trying to work out how to upload multiple files from fileDropzone to google drive.

I can upload single files all day, but banging my head on the syntax that will make google happy. Chat GPT out of ideas on this one.

So far for multi files I have a JS query that loops through the files and triggers the Google Drive query, passing formData in additional scope.

Single Files upload in 2 separate queries, create file (get ID) then upload base64 as binary.

Anyone have some tricks to get me fixed up? Thanks

This is how I am uploading multiple files. Maybe you can add multiple files to the data payload? This uses the multipart method and uploads the metadata and file in one query

image

for (const imageFile of images.files) {
  // Convert image to base64
  const file = await utils.getDataByObjectURL(imageFile.uri);  

  // Upload photo
  const boundary = 'foo_bar_baz';  
  
  let dataURLparts = file.split(',', 2);
  let dataURLheaderParts = dataURLparts[0].split(':');
  let dataURLheaderPayloadParts = dataURLheaderParts[1].split(';');
  let name = door.door_name+moment().unix()+'.' + dataURLheaderPayloadParts[0].split('/')[1];

  const metadata = { 
    "mimeType": dataURLheaderPayloadParts[0],
    "name": name,
    "parents": [ folderid ]
  };
  
  let data = '--' + boundary + '\n';
  data += 'Content-Type: application/json; charset=UTF-8' + '\n\n';
  data += JSON.stringify(metadata) + '\n';
  data += '--' + boundary + '\n';
  data += 'Content-Transfer-Encoding: ' + dataURLheaderPayloadParts[1] + '\n';
  data += 'Content-Type: ' + dataURLheaderPayloadParts[0] + '\n\n';
  data += dataURLparts[1] + '\n';
  data += '--' + boundary + '--';

  console.log("Uploading image " + name);

  const response = await postDriveMultiPart.trigger({
    additionalScope: {
      contenttype: 'multipart/related; boundary=' + boundary,
      data: data
    }
  });

  fileIds.push(response.id);
}