gdrive support

This commit is contained in:
benweet 2013-03-28 23:06:03 +00:00
parent 65f0434cb2
commit 0c13629f1e
2 changed files with 16 additions and 5 deletions

View File

@ -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;
var fileSyncIndex = undefined;
if(file.id) {
fileSyncIndex = SYNC_PROVIDER_GDRIVE + file.id;
localStorage[fileSyncIndex + ".etag"] = file.etag;
}
if (callback) {
callback(fileSyncIndex);
}

View File

@ -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) {
if(fileSyncIndex) {
localStorage[fileIndex + ".sync"] += fileSyncIndex + ";";
}
else {
showError("Error while creating file on Google Drive");
}
});
})(fileIndex);
});