简体   繁体   中英

Is it possible to use the Google Drive API only with Javascript and without Node.JS?

I saw that is possible Upload files using that API through VB.Net and C# for Desktop applications and Node.js, ASP Net for Web applications but I need to know if its possible to achieve it only with Javascript (No node.js) in front end.

Ps: I want to upload files to a Google Drive Service Account.

If you want to upload files using Javascript alone, you probably can do in Google Scripts using the Drive Service. Here are two links which might help:

- Drive Service in Google Scripts

- Google App Scripts Quickstart to call the Drive API

Certainly.


Goole JavaScript client library

You can use the JavaScript client library to interact with Google APIs, such as People, Calendar, and Drive, from your web applications. (developers.google.com)

You need to import the Google API Client Library first.

<script src="https://apis.google.com/js/api.js"></script>

...and initialize it:

function start() {
  // 2. Initialize the JavaScript client library.
    gapi.client.init({
    'apiKey': 'YOUR_API_KEY',
    // Your API key will be automatically added to the Discovery Document URLs.
    'discoveryDocs': ['https://people.googleapis.com/$discovery/rest'],
    // clientId and scope are optional if auth is not required.
    'clientId': 'YOUR_WEB_CLIENT_ID.apps.googleusercontent.com',
    'scope': 'profile',
  }).then( /* your requests go HERE */ )
};
// 1. Load the JavaScript client library.
gapi.load('client', start);

...to finally proceed with your requests.


Links :

In the Quickstart - Javascript documentation page, you will find a simple example of the Drive API usage. https://developers.google.com/drive/v3/web/quickstart/js

And all the detals about the Javascript client library in : https://developers.google.com/api-client-library/javascript/start/start-js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM