event.phase == "progress" gets only fired once - need a progress bar though

Dear Corona community,

I use

network.request(remotePicController, “POST”, uploadListener, params)

to upload two b64 encoded images as a string in params.body. I also set params.progress = “upload” and listen for

elseif ( event.phase == “progress” ) then
print ("Download progress: " … event.bytesTransferred)

The size of my request is ~2MB, so depending on signal strength, it might take a couple of seconds to upload the images. I would like to create a progress bar (or just numbers at the beginning) to indicate how much has been transfered yet.

Unfortunately it prints out the progress only once before event.phase == “ended” is fired. I’d rather get the progress every miliseconds or so.

I did some research, but did not find out whether this behaviour is normal or not. Is there a way to get the progress constantly while uploading something?

Appreciate any help, thanks.

quickly off the top of my head before running out the door,

does bytesEstimated report anything?

if not, it might be hard for corona to know progress of a “unknown size” value

15:19:48.201  Download progress: 65536 from 617746
:slight_smile:

The problem is not the total size though. This one line output is the only progress update I get. I’d rather have something like

15:19:48.201  Download progress: 61536 from 617746
15:19:48.211  Download progress: 62536 from 617746
15:19:48.221  Download progress: 63536 from 617746
15:19:48.231  Download progress: 64536 from 617746
15:19:48.241  Download progress: 65536 from 617746

Hope it gets clearer now :slight_smile:

I think you are not getting progress events as you are not uploading files.  Essentially, all you have 2MB of text.

Try uploading physical files to receive progress events.

Try using this convenience function instead - https://docs.coronalabs.com/api/library/network/upload.html

Thanks Sphere Game Studio, unfortunately that is not an option since I have to further process the images on the server, put them in database and for a couple of other reasons. I can not use network.upload().

I feel like event.phase == progress does not make any sense then when using network.request().

Or did I misunderstand something?

Corona would need to confirm but AFAIK the progress events only work on file upload/download.

Well, at least it is listed in https://docs.coronalabs.com/api/library/network/request.htmlwhere it says:

“progress - An intermediate progress notification.”

"progrss— String value indicating the type of progess notifications desired, if any. May be “upload” or “download”

So, at least to me progress notifications (plural) sounds like I’d get more than the one notification I get.

Corona team, any chance you yould clarify this here?

Thanks a lot!

Update: Ok, it does fire more than once. On simulator and a fast internet connection, the 2.5 MB are uploaded faster than the frequency Corona set up to check the progress.

When I try on my device and use normal mobile data, the progress event is fired three times when uploading 2.5 MB. I feel like it checks every one second-ish or so.

I guess there is no way of checking more often?

Not that I’m aware of.

all right, thanks!

quickly off the top of my head before running out the door,

does bytesEstimated report anything?

if not, it might be hard for corona to know progress of a “unknown size” value

15:19:48.201  Download progress: 65536 from 617746
:slight_smile:

The problem is not the total size though. This one line output is the only progress update I get. I’d rather have something like

15:19:48.201  Download progress: 61536 from 617746
15:19:48.211  Download progress: 62536 from 617746
15:19:48.221  Download progress: 63536 from 617746
15:19:48.231  Download progress: 64536 from 617746
15:19:48.241  Download progress: 65536 from 617746

Hope it gets clearer now :slight_smile:

I think you are not getting progress events as you are not uploading files.  Essentially, all you have 2MB of text.

Try uploading physical files to receive progress events.

Try using this convenience function instead - https://docs.coronalabs.com/api/library/network/upload.html

Thanks Sphere Game Studio, unfortunately that is not an option since I have to further process the images on the server, put them in database and for a couple of other reasons. I can not use network.upload().

I feel like event.phase == progress does not make any sense then when using network.request().

Or did I misunderstand something?

Corona would need to confirm but AFAIK the progress events only work on file upload/download.

Well, at least it is listed in https://docs.coronalabs.com/api/library/network/request.htmlwhere it says:

“progress - An intermediate progress notification.”

"progrss— String value indicating the type of progess notifications desired, if any. May be “upload” or “download”

So, at least to me progress notifications (plural) sounds like I’d get more than the one notification I get.

Corona team, any chance you yould clarify this here?

Thanks a lot!

Update: Ok, it does fire more than once. On simulator and a fast internet connection, the 2.5 MB are uploaded faster than the frequency Corona set up to check the progress.

When I try on my device and use normal mobile data, the progress event is fired three times when uploading 2.5 MB. I feel like it checks every one second-ish or so.

I guess there is no way of checking more often?

Not that I’m aware of.

all right, thanks!