I want download somfile(ex.Zip,Jpg,Png) with progressBar.
But Corona sdk have only Network.download. It have only finish Callback function.
So I try implementation with network.request and Event Looping.
But. network.request
argument(event) of Callback function Type is “string”(event.response).
I want to wirte binary file.
But it is wrong binary file
source file Hex code : 8950 4e47 0d0a 1a0a 0000 000d 4948 4452 .PNG…IHDR
download Hex code : efbf bd50 4e47 0d0a 1a0a efbf bd28 52ef …PNG…(R.
[Source code]
function networkListener( event )
print(“get Event [”…event.status…"]/"…type(event.status))
if ( event.isError ) then
print( “Network error!”)
elseif (event.status == 416) then
print( “End File”)
elseif (event.status == 206) then
print (“event.url :”… event.url)
print (“event.name :”… event.name)
print ("#event.response :"… #event.response)
print (“event.status :”… event.status)
local path = system.pathForFile( “hello.png”, system.DocumentsDirectory )
myFile = io.open( path, “a” )
ltn12.pump.all(
ltn12.source.string(event.response),
ltn12.sink.file(myFile)
)
getPacket(event.url)
end
end
help Me…SOS… [import]uid: 175601 topic_id: 30878 reply_id: 330878[/import]