4

can anybody suggest me how to upload a file from my app's local storage directory to google drive using javascript in titanium Appcelerator.

i have tried the following code but it is not uploading the file.. thought some one can help me by seeing this code

code :

 var ggParams = {
clientId: '662194379016.apps.googleusercontent.com',
clientSecret: 'ffRSIWBlXyPwW-M1iQ6DNtXZ',
redirectUri: 'http://localhost', //urn:ietf:wg:oauth:2.0:oob  
devKey: 'AIzaSyBmXhfsc--2CdlSU8UD37Ryyd3qYaUxKls',
};
// Initialize Youtube Service
 var google = new Google(ggParams);
 google.login(function(e){
Ti.API.info('Token: ' + google.accessToken());
}); 
/* google.refreshToken(function(e){
    Ti.API.info('New Token: ' + e.token);

});*/  

 /*var params = {
    call: 'userinfo',
    method: 'GET',
    params: {
        client_id: '662194379016.apps.googleusercontent.com',
        client_secret: 'ffRSIWBlXyPwW-M1iQ6DNtXZ',
        redirect_uri: 'http://localhost', //urn:ietf:wg:oauth:2.0:oob  
        devKey: 'AIzaSyBmXhfsc--2CdlSU8UD37Ryyd3qYaUxKls',
        code:''
        }
};*/
google.callMethod( 
 args = {
    call: 'drive',  //token
    method: 'GET', //POST
    params: {
        clientId: '662194379016.apps.googleusercontent.com',
        clientSecret: 'ffRSIWBlXyPwW-M1iQ6DNtXZ',
        redirectUri: 'http://localhost', //urn:ietf:wg:oauth:2.0:oob  
        devKey: 'AIzaSyBmXhfsc--2CdlSU8UD37Ryyd3qYaUxKls',
         code: 200
        }
},
function(e){

    if (e.success){
        callback(e.data);
        Ti.API.info(e.data);
    }
    else{
        Ti.API.info(e.data);
        Ti.API.error('Error getting tokens');

    }
}, false); //true or false or null
user2732609
  • 53
  • 1
  • 2
  • 6

1 Answers1

1

You need to check for Google API Java Client Upload to Google Docs

This is a sample Android application which uses the google-api-java-client library to demonstrate uploading a file to Google Docs.

This app will

  • Perform OAuth2 authorization against Google Docs
  • Create a folder (known as a collection) in Google Docs
  • Upload a file to Google Docs (inside that folder)
  • Update a file on Google Docs

Take a QuickStart to Google Drive API

GrIsHu
  • 29,068
  • 10
  • 64
  • 102
  • Actually i have seen this before.. couldn't understand. Moreover i have also posted a Query yesterday no one has replied me ... link is http://stackoverflow.com/questions/18606961/can-somebody-help-me-how-to-upload-the-file-into-box-com-from-the-app – user2732609 Sep 05 '13 at 05:31
  • i just try quickstart sample i have some error please see this....http://stackoverflow.com/questions/27636659/upload-file-to-google-drive-using-google-play-serivces-libwithout-supporting-ja please help me – Dinesh R Rajput Dec 25 '14 at 10:05