Upload file to google drive with appcelerator android -
how can upload file appcelerator titanium google drive titanium
already tried below function oauth2 token.
what missing?
function uploadfile(myaccesstoken) { var base64image = ti.utils.base64encode(blobdata); //convert blob base64 encoded string var myfilename = "myimage.png"; var reqbody = '--foo_bar_baz\ncontent-type: application/json; charset=utf-8\n\n{"title": "' + myfilename + '"}\n--foo_bar_baz\ncontent-type: image/jpeg\ncontent-transfer-encoding: base64\n\n' + base64image + '\n--foo_bar_baz--'; var url = "https://www.googleapis.com/upload/drive/v2/files"; var client = ti.network.createhttpclient({ onload : function(e) { ti.api.info("received text: " + this.responsetext); alert('success'); }, onerror : function(e) { ti.api.debug(e.error); alert('error'); }, timeout : 100000000 }); client.open("post", url); client.setrequestheader('authorization', "bearer " + myaccesstoken); client.setrequestheader('content-type', 'multipart/related; boundary="foo_bar_baz"' ); client.send(reqbody); }
Comments
Post a Comment