Skip to content

Instantly share code, notes, and snippets.

@MartinGonzalez
Created January 14, 2019 00:06
Show Gist options
  • Save MartinGonzalez/9cf48d46e0ec324d0797b100dcdd4113 to your computer and use it in GitHub Desktop.
Save MartinGonzalez/9cf48d46e0ec324d0797b100dcdd4113 to your computer and use it in GitHub Desktop.
const fs = require('fs');
const { google } = require('googleapis');
const express = require('express')
const app = express()
const port = 3000
//https://docs.google.com/presentation/d/HERE_IS_THE_FILE_ID
const slideId = "1gieOtIvgm3fm7-WvLdScVPCuVKvwFZVmhEaa39rfOdE"
app.get('/', (req, res) => {
var data = '';
const drive = google.drive({ version: 'v3', auth: 'YOUR_API_KEY' });
const fileStream = fs.createWriteStream('./output.pdf')
res.contentType('application/pdf')
drive.files.export({ fileId: slideId, mimeType: 'application/pdf' }, { responseType: 'stream' }, (err, response) => {
response.data.on('data', function(chunk) {
data += chunk;
res.write(chunk)
});
response.data.on('end', function() {
res.end(undefined, 'binary')
});
})
})
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment