Download a file, upload to Google Drive
@dylburger
code:
data:privatelast updated:3 years ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 800,000+ developers using the Pipedream platform
steps.
trigger
Cron Scheduler
Deploy to configure a custom schedule
This workflow runs on Pipedream's servers and is triggered on a custom schedule.
steps.
download_file_to_tmp_dir
auth
to use OAuth tokens and API keys in code via theauths object
params
URL

Take a screenshot of this URL

 
https://example.com
string ·params.url
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps, params) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
}
14
const axios = require('axios')
const fs = require("fs")

const { url } = params

const { data } = await axios({
  method: 'GET',
  url,
  responseType: 'arraybuffer',
})

fs.writeFileSync(`/tmp/file`, data)
steps.
upload_file_to_folder_by_file_path
Allows you to upload a file previously-saved to the /tmp directory, by passing in the path to that file
auth
(auths.google_drive)
params
Filename
test.png
string ·params.filename
Parent Folders

A list of parent folder IDs, entered manually or retrieved from a previous file list operation

[0]:
15_pt6AQWPGxg9amYZ1jbckCFQUAQR7Wd
array ·params.parents
Filetype
image/png
string ·params.filetype
File path

The path to the file, e.g. /tmp/myFile.csv .

/tmp/file
string ·params.pathToFile
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
}
22
const fs = require("fs")
const {google} = require('googleapis')

const driveAuth = new google.auth.OAuth2()
driveAuth.setCredentials({ access_token: auths.google_drive.oauth_access_token })
const drive = await google.drive({ version: 'v3', auth: driveAuth });

this.uploadResponse = (await drive.files.create({
  resource: {
    name: params.filename,
    originalFilename: params.filename,
    parents: params.parents,
  },
  media: {
    mimeType: params.filetype,
    uploadType: "media",
    body: fs.createReadStream(params.pathToFile)
  },
  fields: '*'
})).data