Duaer

App recipes

Save Gmail attachments to Google Drive automatically with Duaer

In Duaer, each new email with attachments uploads every file under its original name to a Google Drive folder.

Build the attachment archive in Duaer

  1. Add Gmail Trigger, turn off Simplify, turn on Download Attachments under Options, and set Search under Filters to has:attachment.
  2. Attachments land on attachment_0, attachment_1, and so on. Add Code with the code below for one item per file, each on data.
  3. To keep only PDFs, add If with {{ $json.fileName.toLowerCase().endsWith('.pdf') }} is true.
  4. Add Google Drive with Resource File and Operation Upload; Input Data Field Name data, File Name {{ $json.fileName }}, then pick Parent Drive and Parent Folder.
  5. Publish the digital organization.
const out = [];
for (const item of $input.all()) {
  for (const key of Object.keys(item.binary ?? {})) {
    out.push({
      json: { ...item.json, fileName: item.binary[key].fileName },
      binary: { data: item.binary[key] },
    });
  }
}
return out;

Folders by sender or month

Prefix File Name with a date, such as {{ $now.toFormat('yyyy-MM') }}-{{ $json.fileName }}. For real folders, create them with the Google Drive Folder create operation first, then set Parent Folder by expression.

Questions

Does Duaer save the same attachments twice?

No. The Duaer Gmail Trigger fires once per new email; only a manual rerun uploads again.

Can Duaer save attachments from a non-Gmail mailbox?

Yes. Swap Gmail Trigger for Email Trigger (IMAP) with attachment download on; the rest of the Duaer flow stays the same.

In this section