How to build a Pipedream workflow for uploading files to Google Drive when a new Notion database entry is made?

This topic was automatically generated from Slack. You can find the original thread here.

hello guys, just stumbled upon pipedream. looks great. i wanted to build a quick workflow where i upload a file to google drive anytime a new notion database entry has been made. i chose “new database entry” from notion as trigger and “upload to drive” as a next step. however i seem to fail to identify the PDF document as i get error messages when trying to upload. the pdf is stored within the notion page as it is uploaded from a mobile scanner app

Hi , I think your question is a great case for Pipedream bot to help. I’ll pass your question to the Pipedream bot now. Please feel free to ask it any question

hello guys, just stumbled upon pipedream. looks great. i wanted to build a quick workflow where i upload a file to google drive anytime a new notion database entry has been made. i chose “new database entry” from notion as trigger and “upload to drive” as a next step. however i seem to fail to identify the PDF document as i get error messages when trying to upload. the pdf is stored within the notion page as it is uploaded from a mobile scanner app

how does that work?

To achieve your goal of uploading a PDF file to Google Drive when a new Notion database entry is created, you’ll need to make sure you’re correctly identifying and accessing the PDF file within the Notion page. First, ensure that the Notion API returns the URL of the PDF file. You can do this by inspecting the properties of the database entry in the trigger step. If you can locate the URL of the PDF, you can use it in the next step. Next, you’ll need to download the PDF file using an HTTP request before uploading it to Google Drive. You can add a new step using a “Run Node.js code” action and use the following code to download the PDF: import { axios } from "@pipedream/platform"; const pdfUrl = "URL_OF_THE_PDF"; // Replace this with the actual URL of the PDF from the Notion API response const response = await axios(this, { method: "GET", url: pdfUrl, responseType: "arraybuffer", }); return { data: response.data }; This code downloads the PDF file and returns its content as an ArrayBuffer. Make sure to replace URL_OF_THE_PDF with the actual URL you obtained from the Notion API response. Finally, in the “Upload to Google Drive” step, you’ll need to pass the downloaded PDF data as the file parameter. You can do this by referencing the previous step’s output like this: {{steps.nodejs_code_name.data}}, where nodejs_code_name should be replaced with the actual name of the “Run Node.js code” step. This should allow you to upload the PDF file to Google Drive whenever a new Notion database entry is created. If you’re still encountering issues, please provide more information about the error messages you’re receiving, and I’ll be happy to help you further.