Google Drive support

This commit is contained in:
benweet 2013-03-24 19:20:01 +00:00
parent 0e96a56e8d
commit 3f99c8cc4d

View File

@ -14,7 +14,8 @@
<script type="text/javascript" src="js/main.js"></script>
<script type="text/javascript">
var CLIENT_ID = '241271498917-jpto9lls9fqnem1e4h6ppds9uob8rpvu.apps.googleusercontent.com';
var SCOPES = 'https://www.googleapis.com/auth/drive.install';
var SCOPES = ['https://www.googleapis.com/auth/drive.install', 'https://www.googleapis.com/auth/drive.file'];
var driveUpload = false;
/**
* Called when the client library is loaded to start the auth flow.
@ -39,6 +40,9 @@
function handleAuthResult(authResult) {
if (authResult && !authResult.error) {
$("#drive-link").hide();
gapi.client.load('drive', 'v2', function() {
driveUpload = true;
});
} else {
$("#drive-link").click(function() {
gapi.auth.authorize({ 'client_id' : CLIENT_ID,
@ -67,6 +71,7 @@
* @param {Function} callback Function to call when the request is complete.
*/
function insertFile(fileData, callback) {
if(driveUpload) {
var request = gapi.client.request({
'path' : '/upload/drive/v2/files',
'method' : 'POST',
@ -79,6 +84,7 @@
};
}
request.execute(callback);
}
}
</script>
<script type="text/javascript"