Skip to content

Instantly share code, notes, and snippets.

@rfaisal
Created February 2, 2015 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfaisal/eed03c9ed0ff7f254053 to your computer and use it in GitHub Desktop.
Save rfaisal/eed03c9ed0ff7f254053 to your computer and use it in GitHub Desktop.
MobileServiceClient.prototype.uploadBlob=function(blob, sasUrl, callBack){
var xhr = Titanium.Network.createHTTPClient();
xhr.setTimeout(this.REQUEST_TIMEOUT);
xhr.onload=function() {
var o = JSON.parse(this.responseText);
if(o && o['error']) callBack(o['error'],null);
else callBack(null,o);
};
xhr.onerror= function(e) {
callBack(e,null);
};
xhr.open("PUT", sasUrl);
xhr.setRequestHeader("Content-Type", "image/jpeg");
xhr.send(blob);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment