flydrive-google-drive
This is GoogleDrive access driver for node-flydrive library
Dependencies
This package depends on google-auth-library, you can get it by running
npm i --save google-auth-library
The google-auth-library
permits using OAuth for google drive authentication, its main role is to get a new token from refresh token if any
Installation
You can get this package by running just
npm i --save flydrive-google-drive
Usage
With flydrive library
You need to install @slynova/flydrive that is a fluent nodejs storage library
npm i --save @slynova/flydrive
And now you just import StorageManager from flydrive and register flydrive-google-drive
const StorageManager = const GoogleDriver = const storageManager = default: 'googledrive' 'disks': 'local': 'driver': 'local' 'root': process 's3': 'driver': 's3' 'key': 'AWS_S3_KEY' 'secret': 'AWS_S3_SECRET' 'region': 'AWS_S3_REGION' 'bucket': 'AWS_S3_BUCKET' 'googledrive': 'driver': 'googledrive' 'clientId': 'GOOGLE_DRIVE_CLIENT_ID' 'clientSecret': 'GOOGLE_DRIVE_CLIENT_SECRET' 'redirectUrl': 'GOOGLE_DRIVE_REDIRECT_URL' 'access_token': 'GOOGLE_DRIVE_ACCESS_TOKEN' 'refresh_token': 'GOOGLE_DRIVE_REFRESH_TOKEN' storageManager
You can now call file operation method from on a Storage object instance that you can get from storage manager
{ const storage = storageManager let file = await storage file = await storage const content = await storage const r = await storage}
Please refer to flydrive wiki for more information about this
Use as standlone
You can use this library standlone
Import GoogleDrive
const GoogleDriver =
Create an instance of the GoogleDrive
const config = 'clientId': 'GOOGLE_DRIVE_CLIENT_ID' 'clientSecret': 'GOOGLE_DRIVE_CLIENT_SECRET' 'redirectUrl': 'GOOGLE_DRIVE_REDIRECT_URL' 'access_token': 'GOOGLE_DRIVE_ACCESS_TOKEN' 'refresh_token': 'GOOGLE_DRIVE_REFRESH_TOKEN' { const drive = config; //if you provide a refresh token , this will be used to get a new token on each request, to ensure there is not authentication error let r =await drive; if!r await drive let file = await drive const content = await drive ; console }
Licence
MIT