gdrive support
This commit is contained in:
parent
65f0434cb2
commit
0c13629f1e
@ -41,7 +41,7 @@ var gdrive = (function() {
|
||||
var method = 'POST';
|
||||
if (fileId) {
|
||||
// If it's an update
|
||||
path += fileId;
|
||||
path += "/" + fileId;
|
||||
method = 'PUT';
|
||||
}
|
||||
|
||||
@ -60,8 +60,11 @@ var gdrive = (function() {
|
||||
+ boundary + '"', }, 'body' : multipartRequestBody, });
|
||||
request.execute(function(file) {
|
||||
unsetWorkingIndicator(FLAG_GDRIVE_UPLOAD);
|
||||
var fileSyncIndex = SYNC_PROVIDER_GDRIVE + file.id;
|
||||
localStorage[fileSyncIndex + ".etag"] = file.etag;
|
||||
var fileSyncIndex = undefined;
|
||||
if(file.id) {
|
||||
fileSyncIndex = SYNC_PROVIDER_GDRIVE + file.id;
|
||||
localStorage[fileSyncIndex + ".etag"] = file.etag;
|
||||
}
|
||||
if (callback) {
|
||||
callback(fileSyncIndex);
|
||||
}
|
||||
|
12
js/main.js
12
js/main.js
@ -59,7 +59,10 @@ var synchronizer = (function($) {
|
||||
// Try to find the provider
|
||||
if(fileSyncIndex.indexOf(SYNC_PROVIDER_GDRIVE) === 0) {
|
||||
var id = fileSyncIndex.substring(SYNC_PROVIDER_GDRIVE.length);
|
||||
gdrive.updateFile(id, title, content, function() {
|
||||
gdrive.updateFile(id, title, content, function(result) {
|
||||
if(!result) {
|
||||
showError("Error while uploading file on Google Drive");
|
||||
}
|
||||
sync(fileSyncIndexList, content, title);
|
||||
});
|
||||
} else {
|
||||
@ -140,7 +143,12 @@ var fileManager = (function($) {
|
||||
var title = localStorage[fileIndex + ".title"];
|
||||
(function(fileIndex) {
|
||||
gdrive.createFile(title, content, function(fileSyncIndex) {
|
||||
localStorage[fileIndex + ".sync"] += fileSyncIndex + ";";
|
||||
if(fileSyncIndex) {
|
||||
localStorage[fileIndex + ".sync"] += fileSyncIndex + ";";
|
||||
}
|
||||
else {
|
||||
showError("Error while creating file on Google Drive");
|
||||
}
|
||||
});
|
||||
})(fileIndex);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user