Google Drive API client for Web Application.
CAUTION:
After v2.0.0, The API loadApi is changed. It needs clientSecret at its second
parameter instead of apiKey.
It is needed to clear the cookies of the web pages running by command npm start
or
npm run web-test
. On the pages, the API key has been saved to cookies to connect
Google drive APIs.
A brief explanation is described in a documet for the class Gdfs.
- Class Gdfs as a client of the Google Drive file system.
- Class methods
- async
loadApi(clientId, clientSecret)
loads Google Drive APIs(v3) and initializes its client. isSignedIn()
tests the client is signed-in to the Google Drive.- async
signIn()
signs-in with a Google Account. - async
signOut()
signs-out.
- async
- Instance methods
- async
chdir(directory)
changes the current working directory. cwd()
- returns the current working directory.- async
isDirectory(path)
tests the path is a directory. - async
mkdir(path)
creates a folder. - async
readdir(path, options)
lists file names. - async
readFile(path)
read the file contents. - async
rmdir(path)
removes the directory. - async
stat(path)
returns properties of Google Drive files. - async
unlink(path)
removes the file (without moving to the trash-box). - async
writeFile(path, mimeType, data)
writes data to the file.
- async
- Class methods
- Class Gdfs.Path - as representation of path for the Google Drive files.
- Class Gdfs.Ui(alpha) - A class supporting to create UI.
To install, use npm for your project.
$ npm install --save gdrive-fs
If you are using some bundler, you can just import this module and use.
const Gdfs = require("gdrive-fs");
Gdfs.loadApi(
.
.
.
If you do not use any bundler, the following built files are available to include by SCRIPT tag.
node_module/gdrive-fs/build/grive-fs.min.js
node_module/gdrive-fs/build/grive-fs.js
<!DOCTYPE html>
<html>
<head>
...
<script src="<path-to-gdrive-fs>/build/gdrive-fs.min.js"></script>
</body>
$ npm run release
This module published under MIT LICENSE.