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