I am trying to download a pdf document from drive. Update it locally and then upload the updated document back into the drive. The api documentation shows that I can pipe the get request to a writeable stream. But I am getting an error that pipe is not a function. Tried looking around for a solution finally came across this and thought of asking for help here.
Greetings! Can you share a small example of the code you're using?
Greetings!
I am using below snippet from the documentation...
let drive = google.drive({ version: 'v3', auth });
let dest = fs.createWriteStream(path.join(__dirname, '../temp/', filename));
drive.files.get({
fileId: fileId,
alt: 'media'
})
.on('end', function () {
console.log('Done');
})
.on('error', function (err) {
console.log('Error during download', err);
})
.pipe(dest);
as is...I was getting errors about the ons initially...So, I tried removing them and using the pipe to dest directly as well...No luck...
Got it - can you share the doc where you're finding this? This is a far better example:
https://github.com/googleapis/google-api-nodejs-client/blob/master/samples/drive/download.js
I found this at
https://developers.google.com/drive/api/v3/manage-downloads
Thanks for pointing me to another example...Will take a look at it...
Ok, the example at the new Url provided works for me...Thanks a lot...
Sei que faz tempo, mas talvez ajude alguma outra pessoa....
drive.files.get({
fileId: fileId,
alt: 'media'
}).then(result => {
console.log(result);
}).catch(err=>{
console.log(err);
})
Como pode ver, est谩 retornando uma promisse.
Greetings, we're closing this. Looks like the issue got resolved. Please let us know if the issue needs to be reopened.
Most helpful comment
Got it - can you share the doc where you're finding this? This is a far better example:
https://github.com/googleapis/google-api-nodejs-client/blob/master/samples/drive/download.js