I am trying to download an mp3 file from a server but the app crashes. The file gets created, gets some data in the file and then a crash. Here is what i am trying:
var file = Ti.Filesystem.getFile(directory.nativePath(), filename);
var httpClient = Ti.Network.createHTTPClient();
httpClient.open('GET', URL);
httpClient.receive(function(data) {
var fileStream = Ti.Filesystem.getFileStream(file);
fileStream.open(Ti.Filesystem.MODE_WRITE, true);
fileStream.write(data);
fileStream.close();
});
thanks.