Created
May 13, 2014 23:13
-
-
Save pedrobrasileiro/a545a687fed173557a37 to your computer and use it in GitHub Desktop.
Upload Photo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = Ti.Network.createHTTPClient({ | |
onerror : function(e) { | |
console.error('Error Send Photo : '+ e); | |
args.error(e); | |
}, | |
onload : function () { | |
console.debug('Success Send Photo : '+ JSON.stringify(data)); | |
args.success({responseText : this.responseText}); | |
}, | |
onsendstream : function(e) { | |
if (abortSendPhoto == true) { | |
console.debug("Aborting Photo Upload..."); | |
http.abort(); | |
abortSendPhoto = false; | |
} | |
args.progress(e); | |
} | |
}); | |
var data = { | |
uploadedFile : args.media | |
}; | |
console.debug('Send Photo : '+ args.url); | |
http.open('POST', args.url); | |
http.setRequestHeader('enctype','multipart/form-data'); | |
http.setRequestHeader('Content-Length', args.media.length); | |
http.setRequestHeader('Connection', 'close'); | |
http.send(data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment