I’m new to n8n and am transitioning my workflows from MAKE to n8n. I’ve been experimenting with it in my lab environment and plan to migrate everything to the n8n cloud shortly. While it’s been exciting, I’ve found it somewhat less intuitive than expected, which is understandable.
I want to express my gratitude to those who have worked diligently on n8n. It’s a truly remarkable tool! Thank you for your time and dedication.
To better understand n8n’s functionality, I have a few questions about binaries. I primarily work with Google’s platform and services, such as Google Sheets, Docs, Calendar, and Gmail.
Currently, I’m testing a simple workflow: whenever a new PDF file is uploaded to a Google Drive folder, I want to download it, attach it to an email, and send it using Gmail.
When I run this workflow, I encounter an error indicating that the binary file was not found. The suggested solution i found on the web is to add a “Read/Write to disk” node before attaching the file to the email. Is this the correct approach, or am I missing something? Why is it necessary to convert the file to a binary format before attaching it to the email?
In a similar workflow, I’m trying to upload a file to a different Google Drive folder and then send the newly uploaded file’s link in an email. I haven’t been able to find a way to accomplish this.
When a file is downloaded and becomes part of the workflow, where does n8n save the temporary file?
Please don’t hesitate to ask if my questions seem basic or uninformed. They are currently the missing pieces in my n8n learning journey.
I am using n8n version 1.57
Database: Default
n8n EXECUTIONS_PROCESS setting (default: own, main): not sure what this is
Running n8n via: Docker
Operating system: Ubuntu Server
Describe the problem/error/question
What is the error message (if any)?
Please share your workflow
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
Thanks, JayF,
i was able to follow the example, however, I am facing a new issue: after I download the file and unzip it, the files are present as binary data (under the binary tab) with the correct name and size, but an IF filter to filter only the pdf is not able to locate the file.
The goal of the workflow is to download the zip file, unzip it, extract the pdf, email it as an attachment using gmail (but it is not working)
The problem is less that the data is lost and more that the conditions do not currently work as you expect them (it currently checks if the string filename ends with .pdf, which is not the case). For that reason, the item gets filtered out and so ends up in “Discarded” instead of “Kept.”
What you need to do is to change the field to “Expression” (like that the parameter value gets set dynamically) and then set it to:
{{ $binary.data.fileName }}
That should solve your problem. You can also get a little bit more fancy and convert the values automatically to lowercase to avoid having multiple conditions (no more check for .PDF and .pdf). That is possible by using the method .toLowerCase():
This is a good opportunity to learn how to debug. Put a Code node in place of the Filter and do console.log($binary), then look at your developer console output. It will show the structure of the input. $binary.data.fileName should be correct, so it’s likely you haven’t ran your previous node properly
If i add his code, it passes the pdf file, but it seems to be an empty file:
// Get the binary object
let binaryData = $binary;
// Initialize an empty object to hold only .pdf files
let filteredData = {};
// Loop through the binary object and filter only PDF files
for (let key in binaryData) {
if (binaryData[key].fileExtension === 'pdf') {
filteredData[key] = binaryData[key]; // Add .pdf file to the filteredData object
}
}
// Log the filtered .pdf data to inspect
console.log(filteredData);
// Replace the binary data with only the filtered .pdf files
return [{ json: {}, binary: filteredData }];