Create archive from Firestore images

Hi everyone,

I’m trying to create an archive (zip) from images stored in a Firestore sub collection. Every document in the sub collection has 2 fields: documetName and documentUrl. Before adding the files to the archive I need to convert it to jpg and update the name (increment every filename: PJ1.jpg, PJ2.jpg, PJ3.jpg, etc…).

This is what i managed to do so far:

1- Webhook module to get the document reference of my firestore sub collection.
2- Firestore - List document module to list every doc in the sub collection.
3- Iterator module to output every document as a separate bundle.
4- Parse json module to the data after the iterator.

5- HTTP- get a file module to retrieve the images on every firestore document.

6- Image module to convert the image in jpg format and update filename.

7- An array aggregator module to regroup the data in one bundle.

8- Create an archive module to create a 1 zip with every image in the sub collection.

9- Google drive - Upload a file to store the archive.

Everything works except the archive module. Instead of adding every renamed images from the sub collection to the archive, it create an archive for every file. And the Image -Convert a format module output a file but whithout extension but in the module config I set output format as JPG.

Any idea what I’m doing wrong ? Also if someone known a smarter or more / efficient way of achieving my purpose, please let me know. Thanks in advance.

Welcome to the Make community!

The “Create an Archive” module is already an aggregator.

Hence, you can simply delete the Array Aggregator before it.

Combining Bundles Using Aggregators

Every result (item/record) from trigger/iterator/list/search/match modules 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.

You can find out more about the other types of aggregator modules here:

Question: Which is the best aggregator do you think you’ll need for your use-case?

@samliew
P.S.: investing some effort into the tutorials in the Make Academy will save you lots of time and frustration using Make!

1 Like

Hello,

Welcome to the community!

The Archive module works as an array aggregator, so you need to map it correctly to the aggregated output from Firestore. There is no need to use aggregator.

I prepared a sample scenario- since I don’t have access to any Firestore sandbox right now which I can use, the scenario starts with sample JSON and lorem-photos to simulate the data.

Sample scenario:

Please take a look- I hope this helps you configure your scenario sooner than someone will post exact Firestore config :slight_smile:

Have a great day!
Michal


2 Likes

Hi @samliew and @mszymkowiak thanks for taking the time!

I thougth that the best aggregator for my use case would be the archive zip areator, no ?
I removed the array aggregator as advised and tried the sample scenario parameters @mszymkowiak provided but it doesn’t work in my scenario. It’s funny because when I use the explain flow everything seems good.

I think it’s because of the way datas are stored in my firestore, every image and filename are in a different document so they’re processed individually by the archive module.

Maybe I need a json module to structure the data before archiving it ? Anyway I provided the input and output of the archive module for insight, maybe there is a clue there.

Operation 1
Input

Output

Hi,

Could you share your scenario? It can be via DM.

Also, I’m not sure if thats proper config:

this module gets input from mapping so changing file name should result in error.

1 Like

Yes @mszymkowiak , I didn’t know about that feature :+1:.

Hi, thanks for sharing.

Try this one:

2 Likes

Thank you @mszymkowiak and @samliew it works and it’s more efficient! I spent 2 days trying and I couldn’t figure it out.

The only thing I didn’t thnk about is the order of the documents when they’re listed in the Firestore module. I wanted to use a field present in every document (documentId) to order them but I can’t access that field in the Firestore module since the data hasn’t been treated yet.

You can enter the value manually :slight_smile: Just type your field name and it should work.

1 Like

Damn you’re fast, thanks again Michal now I can upgrade my plan thanks to you.

1 Like