Hi All
| have built a recorder the saves a file and then uploads it to my server the code is below
file = recording.stop(); var newFile =Titanium.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,"/track.m4a"); newFile.write(file); fileToUpload =Titanium.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,"/track.m4a"); var toUpload = fileToUpload.read(); var sendXhr = Titanium.Network.createHTTPClient(); sendXhr.onload = function () { if (this.status === 200) { var response = this.responseData; } else { } // ENDif return status ok } sendXhr.onerror = function(e) { }; sendXhr.open("POST", 'http://example.com/appupload', false); sendXhr.setRequestHeader('Content-Type', 'application/json'); sendXhr.send({media: toUpload});Ok this works fine for ios but as soon as i try with android it fails.
I have looked at the docs and see applicationDirectory is only ios so i have tried externalStorageDirectory as i see thats android but i cant seem to get this to work all i want is it to work similar to above save the file somewhere on the phone i can then upload it from there after upload i will be deleting it from the device
Where does android save a file after its been recorded???
Any help would be appreciated
Thanks
1 Answer
For Android,You have to get file from Sdcard,Use
Titanium.Filesystem.getFile(Ti.Filesystem.getExternalStorageDirectory)and push your image in the android sdcard.
Hope it helps.
Your Answer
Think you can help? Login to answer this question!