selfish-google-drive
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "selfish-google-drive", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Google drive api for that access your own account", | ||
@@ -15,5 +15,5 @@ "main": "src/index.js", | ||
], | ||
"repository" : { | ||
"type" : "git", | ||
"url" : "https://github.com/davidasync/selfish-google-drive" | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/davidasync/selfish-google-drive" | ||
}, | ||
@@ -24,3 +24,6 @@ "author": "davidasync", | ||
"bluebird": "^3.5.1", | ||
"file-type": "^7.6.0", | ||
"lodash": "^4.17.5", | ||
"read-chunk": "^2.1.0", | ||
"request": "^2.83.0", | ||
"superagent": "^3.8.2" | ||
@@ -27,0 +30,0 @@ }, |
@@ -11,4 +11,14 @@ # selfish-google-drive | ||
# Usage | ||
##### 1. mkdir | ||
If you use the api for the first time, it will generate `sgd-token.json` (recommended to add it to .gitignore). Everytime you use the api, It will read the json file instead of call the api again to get the token, it will call the google api again if the sgd-token.json expired (expired in 3600s) or invalid. | ||
The sgd-token.json should be like this | ||
```json | ||
{ | ||
"access_token": "somestring", | ||
"token_type": "Bearer", | ||
"expires_in": 3600 | ||
} | ||
``` | ||
To init the package you should provide credential like below from google. | ||
```js | ||
@@ -20,6 +30,16 @@ const credential = { | ||
} | ||
``` | ||
You can check how to generate the credential at [How do I authorise an app (web or installed) without user intervention? | ||
](https://stackoverflow.com/questions/19766912/how-do-i-authorise-an-app-web-or-installed-without-user-intervention) | ||
const sgd =require('selfish-google-drive')(credential); | ||
##### 1. mkdir | ||
Create folder at your google drive | ||
```js | ||
return sgd.mkdir('HADOKE1N').then(console.log) | ||
return sgd.loadToken(true).then(console.log) | ||
// Example return object | ||
// { kind: 'drive#file', | ||
// id: '1rKARa_6zPZPPp4s5_ruOaxZLX6p3aIaE', | ||
// name: 'HADOKE1N', | ||
// mimeType: 'application/vnd.google-apps.folder' } | ||
``` |
@@ -9,2 +9,3 @@ | ||
const wget = require('./lib/wget'); | ||
const scp = require('./lib/scp'); | ||
@@ -19,2 +20,3 @@ const loadToken = require('../utils/loadToken'); | ||
wget, | ||
scp, | ||
}; | ||
@@ -48,4 +50,6 @@ | ||
.catch((response) => { | ||
const responseStatus = response.status || response.statusCode; | ||
// 401 can happened because access token already expired | ||
if (response.status !== 401) { | ||
if (responseStatus !== 401) { | ||
return Bluebird.reject(response.message || response.error || response); | ||
@@ -52,0 +56,0 @@ } |
@@ -7,2 +7,3 @@ module.exports = { | ||
wget: 'https://www.googleapis.com/drive/v3/files', | ||
scp: 'https://www.googleapis.com/upload/drive/v3/files', | ||
}; |
module.exports = { | ||
'application/vnd.google-apps.audio': 'application/zip', | ||
'application/vnd.google-apps.document': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', | ||
'application/vnd.google-apps.drawing': 'image/png', | ||
'application/vnd.google-apps.file': 'application/zip', | ||
'application/vnd.google-apps.folder': 'application/zip', | ||
'application/vnd.google-apps.form': 'application/zip', | ||
'application/vnd.google-apps.fusiontable': 'application/zip', | ||
'application/vnd.google-apps.map': 'application/zip', | ||
'application/vnd.google-apps.photo': 'application/zip', | ||
'application/vnd.google-apps.presentation': 'application/vnd.openxmlformats-officedocument.presentationml.presentation', | ||
'application/vnd.google-apps.script': 'application/zip', | ||
'application/vnd.google-apps.site': 'application/zip', | ||
'application/vnd.google-apps.spreadsheet': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', | ||
'application/vnd.google-apps.drawing': 'image/png', | ||
'application/vnd.google-apps.unknown': 'application/zip', | ||
'application/vnd.google-apps.video': 'application/zip', | ||
'application/vnd.google-apps.drive-sdk': 'application/zip', | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
92247
2600
43
6
4
+ Addedfile-type@^7.6.0
+ Addedread-chunk@^2.1.0
+ Addedrequest@^2.83.0
+ Addedajv@6.12.6(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedfile-type@7.7.1(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedpify@3.0.0(transitive)
+ Addedpsl@1.15.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqs@6.5.3(transitive)
+ Addedread-chunk@2.1.0(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)
- Removedcall-bind@1.0.8(transitive)
- Removedcall-bind-apply-helpers@1.0.1(transitive)
- Removedcall-bound@1.0.2(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddunder-proto@1.0.0(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.0.0(transitive)
- Removedform-data@2.5.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.6(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedmath-intrinsics@1.0.0(transitive)
- Removedobject-inspect@1.13.3(transitive)
- Removedqs@6.13.1(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedside-channel@1.1.0(transitive)
- Removedside-channel-list@1.0.0(transitive)
- Removedside-channel-map@1.0.1(transitive)
- Removedside-channel-weakmap@1.0.2(transitive)