Last active
January 13, 2019 23:05
-
-
Save MartinGonzalez/7739e362e8ca0ac6ed3e7edc45e233b0 to your computer and use it in GitHub Desktop.
Download PDF with Google Drive API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const downloadFileAsPdf = (googleDriveFileId) => { | |
const drive = google.drive({ version: 'v3', auth: 'YOUR_API_KEY' }); | |
const fileStream = fs.createWriteStream('./output.pdf') | |
drive.files.export({ fileId: googleDriveFileId, mimeType: 'application/pdf' }, { responseType: 'stream' }, (err, res) => { | |
res.data.pipe(fileStream); | |
}) | |
} | |
//https://docs.google.com/presentation/d/HERE_IS_THE_FILE_ID | |
const slideId = "GOOGLE_DRIVE_FILE_ID" | |
downloadFileAsPdf(slideId) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment