using network.request for async file download with progress bar.

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]

Currently there is no way to monitor the download progress with Corona. Your best bet is to use native.setActivityIndicator(true) to show it’s busy and in the network.download/network.request call back call native.setActivityIndicator(false) to turn it off.

[import]uid: 19626 topic_id: 30878 reply_id: 123526[/import]

Currently there is no way to monitor the download progress with Corona. Your best bet is to use native.setActivityIndicator(true) to show it’s busy and in the network.download/network.request call back call native.setActivityIndicator(false) to turn it off.

[import]uid: 19626 topic_id: 30878 reply_id: 123526[/import]

Hi!

I’d like to code a progress bar to indicate how many Kb or Mb have been downloaded.
If I understand correctly, this is not yet possible, isn’t it Rob?

Any idea if Corona staff is working on it?

Thanks!

Alberto. [import]uid: 44013 topic_id: 30878 reply_id: 142629[/import]

If you have your heart set on doing a progress bar, the only way to do it with Corona is to write your own download function using sockets. It’s not too complicated, however it is more work than using a built-in Corona download function.

To get started check the Corona docs here:
http://docs.coronalabs.com/api/library/socket/index.html

More specifically look at socket.tcp here in the LuaSockets reference page:
http://w3.impa.br/~diego/software/luasocket/tcp.html#tcp

[import]uid: 56820 topic_id: 30878 reply_id: 142672[/import]

Hi Anderoth!
Thanks for your reply!

I’m not familiar with sockets, but I’m going to have a look and try what you say.

Alberto. [import]uid: 44013 topic_id: 30878 reply_id: 142732[/import]

Hi!

I’d like to code a progress bar to indicate how many Kb or Mb have been downloaded.
If I understand correctly, this is not yet possible, isn’t it Rob?

Any idea if Corona staff is working on it?

Thanks!

Alberto. [import]uid: 44013 topic_id: 30878 reply_id: 142629[/import]

If you have your heart set on doing a progress bar, the only way to do it with Corona is to write your own download function using sockets. It’s not too complicated, however it is more work than using a built-in Corona download function.

To get started check the Corona docs here:
http://docs.coronalabs.com/api/library/socket/index.html

More specifically look at socket.tcp here in the LuaSockets reference page:
http://w3.impa.br/~diego/software/luasocket/tcp.html#tcp

[import]uid: 56820 topic_id: 30878 reply_id: 142672[/import]

Hi Anderoth!
Thanks for your reply!

I’m not familiar with sockets, but I’m going to have a look and try what you say.

Alberto. [import]uid: 44013 topic_id: 30878 reply_id: 142732[/import]

If you have your heart set on doing a progress bar, the only way to do it with Corona is to write your own download function using sockets. It’s not too complicated, however it is more work than using a built-in Corona download function.

To get started check the Corona docs here:
http://docs.coronalabs.com/api/library/socket/index.html

More specifically look at socket.tcp here in the LuaSockets reference page:
http://w3.impa.br/~diego/software/luasocket/tcp.html#tcp

[import]uid: 56820 topic_id: 30878 reply_id: 142672[/import]

Hi Anderoth!
Thanks for your reply!

I’m not familiar with sockets, but I’m going to have a look and try what you say.

Alberto. [import]uid: 44013 topic_id: 30878 reply_id: 142732[/import]

If you have your heart set on doing a progress bar, the only way to do it with Corona is to write your own download function using sockets. It’s not too complicated, however it is more work than using a built-in Corona download function.

To get started check the Corona docs here:
http://docs.coronalabs.com/api/library/socket/index.html

More specifically look at socket.tcp here in the LuaSockets reference page:
http://w3.impa.br/~diego/software/luasocket/tcp.html#tcp

[import]uid: 56820 topic_id: 30878 reply_id: 142672[/import]

Hi Anderoth!
Thanks for your reply!

I’m not familiar with sockets, but I’m going to have a look and try what you say.

Alberto. [import]uid: 44013 topic_id: 30878 reply_id: 142732[/import]

Hi, did anything ever come from this? I know that now the network.request API does support updating the progress on the download.  However, I am wanting to do FTP file transfer and get progress on the download, which is not available.  Did you guys figure out how to work with Lua sockets?

Hi, did anything ever come from this? I know that now the network.request API does support updating the progress on the download.  However, I am wanting to do FTP file transfer and get progress on the download, which is not available.  Did you guys figure out how to work with Lua sockets?