Starting with build 2013.1043, on iOS, Android, Mac and Windows, we are rolling out new functionality within our network api. Network functions like download, request have been enhanced with new functionality. Check out our daily API docs under network and events under networkRequest here, to see how to do things like upload text files in a single call, view bytes transferred and moreā¦
Also, please note that there are a few new functional changes that aren’t backwards compatible. As you can see in the code example below, event responses are now tables which include fileName and baseDirectory. Be careful to ensure that you treat event.response as a table now instead of a string
Here is a simple example of how to use the new event.response table information.
local function networkListener( event )
if ( event.isError ) then
print( "Network error - download failed" )
elseif ( event.phase == "ended" )
print( "displaying response image file" )
myImage = display.newImage( event.response.filename, event.response.baseDirectory, 60, 40 )
myImage.alpha = 0
transition.to( myImage, { alpha = 1.0 } )
end
end
network.download(
"http://developer.anscamobile.com/demo/hello.png",
"GET",
networkListener,
"helloCopy.png",
system.TemporaryDirectory
)




Joe
Great news, especially viewing bytes transferred.
sq2
Is event.bytesTransferred actually progress though? Does it work in the simulator? My quick tests suggest this isn’t the case.
Mustafa
Great updates, just on time!
Perry
One known bug at the moment (daily build 2013.1043) is that network error messages are not showing in Windows XP. We’re looking into it.
Bryan
Thanks for the comments! It’s worth noting that we have extended the message support under Windows XP and we have resolved several small behavioral differences on iOS and Android in the latest daily build.
sq2
Is this in stable builds yet?
Nevin Flanagan
Apparently, event.response is still a string when the call did not specify a file to store the transfer in.
Paulo
Is it compatible with older versions of Android?
I have tested successfully with Kindle (Android 2.3.4), but it fails with Android 2.3.5 (return status -1).