cordova - Upload file to google drive using api with phonegap -


correct me if wrong per faqs went through, read javascript client library https://developers.google.com/api-client-library/javascript/reference/referencedocs used web applications. making mobile app using phonegap wherein user should able upload picture google drive. going through these links: https://developers.google.com/drive/v2/reference/files/insert

an can see, uses javascript client library uploading file. there way can without using library. if how can using pure js or jquery?

thanks


thanks junyoung ... able finish part in log in , authorize. trying upload file drive. examples see use js client library. https://developers.google.com/drive/quickstart-js want execute same without use of gapi.client.request . want use simple post. here code

          const boundary = '-------314159265358979323846';           const delimiter = "\r\n--" + boundary + "\r\n";           const close_delim = "\r\n--" + boundary + "--";            var reader = new filereader();           var filecontent = this.$.fileinput.getfiles()[0];           reader.readasbinarystring(filecontent);           reader.onload = function(e) {               var contenttype = filecontent.type || 'application/octet-stream';               var metadata = {               'title': filecontent.name,               'mimetype': contenttype               };               var base64data = btoa(reader.result);               var multipartrequestbody =               delimiter +               'content-type: application/json\r\n\r\n' + json.stringify(metadata) + delimiter + 'content-type: ' + contenttype + '\r\n' + 'content-transfer-encoding: base64\r\n' + '\r\n' + base64data + close_delim;                var driveajax = new enyo.ajax({                      url: 'https://www.googleapis.com/upload/drive/v2/files',                      method: 'post',                      contenttype: 'multipart/mixed; boundary="' + boundary + '"',                      postbody: multipartrequestbody                   });               driveajax.response(this, "uploadsuccess");               driveajax.error(this, "processerror");               driveajax.go({                     uploadtype:'multipart'               }); 

as can see have replaced gapi.client.request part simple ajax call. doesn't seem work. btw using enyo js framework. can spot issues this?

was there problem integrating drive api phonegap?

drive api http requests , can done pure javascript. therefore, can use jquery ajax calls files.insert(). however, recommend use javascript client. here example of oauth using js client library. please try example phonegap application , ask question again if there problem.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -