Uploading Multiple Files from HTTP Array to Google Drive

How do I properly iterate over an array of file URLs coming from an HTTP response payload and upload all the files to Google Drive? Right now, only one file is being processed and uploaded instead of the entire array.

It seems as though that I am not properly able to map the array. I can see it in the bundles of the HTTP module, but I am unable to pull up the same data with the Iterator and I also tried an Array Aggregator.

Here is the Iterator mapping.

Here is the HTTP get a file module

Here is what I also tried with the Array Aggregator, but it did not make any difference.

I keep only coming up with one file in the folder. This is coming from a survey that has two upload areas. The first one which is the one file I am retrieving is a single photo. The second upload area is my array and will contain multiple photos and files like PDF and XLSX. This scenario triggers with a webhook from GHL, but I had to use an OAuth2 flow to capture the array of files because the webhook was only pulling the URL for the first file. I have tried looking through the help docs, ChatGPT, and the AI help bot in Make, but I am coming up short.
Any help would be greatly appreciated!

-Jonathan

Hello,

apparently, you have an Array of Array. You should map “CustomFields” in your Iterator. It will generate bundles containing “id” and a “Fieldvalue” array. In this list of bundles, you need only the one with “id”=“KUrvTe…” (I’m not 100% sure, I guess from the screenshot, but it has to be the id of your images custom field).
So what you need to do is to add a second Iterator (after the first one), and map the “FieldValue” array coming from the first iterator’s output.
From this second Iterator, you will have all necessary fields, such a URL to download the file.
BUT, since you want to only pick the images, you have to add a filter between the 2 iterators.

Assuming it’s the one with ID=KUrvTe…, in the filter, map the “id” coming from the first Iterator, and in the comparison part, type the ID you want to keep.

When you run it, the first Iterator will generate n bundles, one for each custom field; then the filter will let pass only the custom field with your specific ID, and then the second iterator will generate bundles for the array of images in the custom field.

I hope it helps

Benjamin

2 Likes

First I want to say thank you @Benjamin_from_Make for responding. I really appreciate the help!
I am not sure why that ID is showing up. The ID that holds the array I need is different.
I am unable to find the ID from the pictures below in any of the mapping.



back to the future great scott GIF

Hey Everyone :bangbang:,

I finally found a solution to the issue of dynamically uploading multiple files from an HTTP array into a Google Drive folder. After trying a few approaches and banging my head against the wall a bit, I wanted to share the steps that worked for me.

The Problem:

I had an array of files coming from an HTTP payload, where each payload could include a different number of files, ranging from PDFs to images (JPEG, PNG, etc.). My goal was to download all the files, no matter how many, and upload them to a Google Drive folder. The problem was getting the array of file URLs, filtering them based on file types, and handling the upload seamlessly.

The Solution:

To handle this, I used two Iterators combined with a Filter to target the MIME types and process the files correctly. Here’s a simplified step-by-step of what worked:

  1. First Iterator: Start by iterating through the customFields[] array where the file data is stored.
  2. Filter by MIME Type: Add a filter to ensure you’re processing only the relevant file types (e.g., pdf, jpeg, png, etc.). This filter allows only the files with acceptable mimeType values to pass through.
  3. Second Iterator: After filtering, use a second iterator to loop through the fieldValue[] array, which contains the actual file data.
  4. HTTP Get Module: Use the url field from the second iterator to download the file.
  5. Google Drive Upload: Finally, upload the file using the Google Drive module, mapping the file name and data.

This method ensures that all files are captured and processed properly, no matter how many are included in the original payload. It’s also flexible enough to handle different file types and dynamically adjust based on the array size.

Hope this helps someone down the line. Feel free to ask if you have any questions!



image

2 Likes