Use of node.js with Google Drive API insert / upload

The documentation at https://developers.google.com/drive/v2/reference/files/insert for JavaScript is intended for use of the client-side JS library. Trying to use the corresponding node.js library, I'm running into problems calling request(), since there doesn't appear to be one.

Short of making the network call directly without use of the library, is there an equivalent for the gapi.client.request() function?

Answer1:

I was also looking for similar alternative when using nodejs and calling Google drive API. I am using googleapi. Following code snippet might help to give idea on API.

googleapis .discover('drive', 'v2') .execute(function(err, client) { req = client.drive.files.list() console.log(req); req.execute(function(err, result) { console.log(err); console.log(result); }); });

Answer2:

Not familiar with the Node libary, but typically with Googleapis, you can use the apiclient discovery to build an api service.

You should be able to use the Node API Client to build the Drive service, then call the files.insert method on your service object. https://github.com/google/google-api-nodejs-client/blob/master/lib/googleapis.js

Answer3:

This is still VERY much a work in progress, but it does show how to use the official node.js googleapis module. It looks like they've made good progress since I originally came up with this solution so I'll likely update my approach and the GIST to use OAuth2 rather than JWT very soon.

VERY basic example of how to save content to Google Drive using node.js using googleapis.

人吐槽 人点赞

Recommend

Comment

用户名: 密码:
验证码: 匿名发表

你可以使用这些语言

查看评论:Use of node.js with Google Drive API insert / upload