Google-api-nodejs-client: Unable to download file using drive APIs TypeError: drive.files.get(...).pipe is not a function

Created on 26 Feb 2020  路  7Comments  路  Source: googleapis/google-api-nodejs-client

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.

drive external docs

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

All 7 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lowagner picture lowagner  路  3Comments

JustinBeckwith picture JustinBeckwith  路  3Comments

oliverjessner picture oliverjessner  路  3Comments

ovaris picture ovaris  路  3Comments

skiod picture skiod  路  3Comments