mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-19 01:17:18 +00:00
refactor(gdrive) load
This commit is contained in:
parent
47622e2d4d
commit
5c9afe7171
1 changed files with 13 additions and 15 deletions
|
|
@ -11,23 +11,23 @@ var CloudCmd, Util, DOM, gapi;
|
|||
/**
|
||||
* load google api library
|
||||
*/
|
||||
function load(pCallBack){
|
||||
function load(callback){
|
||||
/* https://code.google.com/p/google-api-javascript-client/ */
|
||||
var lUrl = 'https://apis.google.com/js/client.js';
|
||||
|
||||
DOM.jsload(lUrl, function(){
|
||||
CloudCmd.getModules(function(pModules){
|
||||
var lStorage = Util.findObjByNameInArr(pModules, 'storage'),
|
||||
lGDrive = Util.findObjByNameInArr(lStorage, 'GDrive'),
|
||||
GDriveId = lGDrive && lGDrive.id;
|
||||
CloudCmd.getModules(function(modules){
|
||||
var storage = Util.findObjByNameInArr(modules, 'storage'),
|
||||
gDrive = Util.findObjByNameInArr(storage, 'GDrive'),
|
||||
gDriveId = gDrive && gDrive.id,
|
||||
/* https://developers.google.com/drive/credentials */
|
||||
|
||||
var lCLIENT_ID = GDriveId + '.apps.googleusercontent.com',
|
||||
lSCOPES = 'https://www.googleapis.com/auth/drive',
|
||||
|
||||
clientId = gDriveId + '.apps.googleusercontent.com',
|
||||
scopes = 'https://www.googleapis.com/auth/drive',
|
||||
|
||||
lParams = {
|
||||
'client_id' : lCLIENT_ID,
|
||||
'scope' : lSCOPES,
|
||||
'client_id' : clientId,
|
||||
'scope' : scopes,
|
||||
'immediate' : false
|
||||
};
|
||||
|
||||
|
|
@ -35,9 +35,7 @@ var CloudCmd, Util, DOM, gapi;
|
|||
gapi.auth.authorize(lParams, function(pAuthResult){
|
||||
|
||||
if (pAuthResult && !pAuthResult.error)
|
||||
gapi.client.load('drive', 'v2', function() {
|
||||
Util.exec(pCallBack);
|
||||
});
|
||||
gapi.client.load('drive', 'v2', Util.retExec(callback));
|
||||
});
|
||||
|
||||
}, 1500);
|
||||
|
|
@ -56,8 +54,8 @@ var CloudCmd, Util, DOM, gapi;
|
|||
var lContent = pParams.data,
|
||||
lName = pParams.name,
|
||||
boundary = '-------314159265358979323846',
|
||||
delimiter = "\r\n--" + boundary + "\r\n",
|
||||
close_delim = "\r\n--" + boundary + "--",
|
||||
delimiter = '\r\n--' + boundary + '\r\n',
|
||||
close_delim = '\r\n--' + boundary + '--',
|
||||
|
||||
contentType = pParams.type || 'application/octet-stream',
|
||||
metadata = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue