I apparently don’t understand how network.download works. I have a website with a text file uploaded to it. I would like to read the data within the text file from my app to make app updates as I change the text file data. I’m using network.download to get the text file but instead of downloading the text file I’m downloading the html source code from the website.
Here’s my code. Anybody know why I would be getting the html and not the actual file?
[lua]
local function networkListener( event )
if ( event.isError ) then
print( “Network error - download failed” )
elseif ( event.phase == “began” ) then
print( “Progress Phase: began” )
elseif ( event.phase == “ended” ) then
print( “Displaying response file” )
local path = system.pathForFile( “temp.txt”, system.TemporaryDirectory )
local file = io.open( path, “r” )
for line in file:lines() do
print( line )
end
io.close( file )
file = nil
end
end
local params = {}
params.progress = true
network.download(
“http://brya1659.wix.com/info/PedPTEx.txt”,
“GET”,
networkListener,
params,
“temp.txt”,
system.TemporaryDirectory
)
[/lua]
Thanks for any help,
Guy