Im trying to pull multiple image attachments from a gmail and send them to chatGPT.
When its multiple attachments it turns into an array and then I can only pull useless data like filename, filetype, MIME type etc - not the actual image file. I’ve used iterators and aggregators but its all the same data, never the actual image file
How can I get the actual images from an attachment in gmail?
Welcome to the Make community!
You’ll need to use the Gmail “Iterate Attachments” module, with the Array Aggregator trick, described below.
Aggregators
Every result (item/record) from a list/search/match module will output a bundle. This can result in multiple bundles, which then trigger multiple operations in future modules (one operation per bundle). To “combine” multiple bundles into a single variable, you’ll need to use an aggregator of some sort.
Aggregators are modules that accumulate multiple bundles into one single bundle. An example of a commonly-used aggregator module is the Array aggregator module. The next popular aggregator is the Text Aggregator which is very flexible and can apply to many use-cases like building of JSON, CSV, HTML.
There are other types of aggregator modules, click the below links to find out more:
Array Aggregator – mapping multiple bundles into a complex field
The Array Aggregator module is very powerful because it allows you to build a complex array of collections for a later module’s field to map multiple items (collections) to it.
This is done using the “Target structure type” of an Array Aggregator module.
Here is an example:
As you can see, the “Map” toggle on complex fields are used when you have an array. You can easily build an array variable to map to a future module’s field, by using an Array Aggregator module and select the “Target Structure Type” as the future module’s field you have mapped the array into.
Hope this helps! Let me know if there are any further questions or issues.
— @samliew
Thanks but as explained in my question, I have tried this and it doesn’t give me the image URL of the attachments, just more bundles of file names and MIME types etc - How do you get the actual image URL from gmail attachments
That is correct. There are no image URLs as the attachments from Gmail are the actual files including the file content (data).
Hope this helps! Let me know if there are any further questions or issues.
— @samliew
Ok thanks. For anyone else who runs into this. I saved the gmail attachments (filename and data) to WordPress media library which then allowed me to access the files URL through WordPress get media.
1 Like