Resuming a cancelled network.download()

Hi,

I need to resume a network.download() call which was cancelled by an applicationSuspend system event or a network.cancel() call.

I can obviously just remember the url and try to download the file again on applicationResume but then I have to start from scratch, i.e. download the complete file again. I would like to download just the missing part of the file I failed to download completely in the first attempt.

network.download() internally saves the file it downloads to a temporary file with a temporary name such as download-E3446515-F0F8-4190-A433-29475F0DF8D6. Sadly enough this file is erased on an applicationSuspend system event.

My plan was to provide a HTTP header such “Range: bytes=121432-” whenever I try with a second call to network.download() and then prepend the partial file (from the first attempt) to the file from the second attempt but alas that is not possible (see above).

Any hints on how to proceed?

Btw, the network module is such a nice piece of engineering. A solid async API combined with high performance. Thanks.

Cheers

/Joakim

I wrote my own async network module (with the same API as the built-in network module) using luasocket and luaproc. It (optionally) keeps partially downloaded files on system suspend and also do socksv5 bridging and more. On to the next task.

Cheers

/Joakim

Nice job!

I do a lot of downloads, but I haven’t looked into this before, but I can see how handy this would be.

Nail

Perhaps this could become part of the Corona library offering…?

I wrote my own async network module (with the same API as the built-in network module) using luasocket and luaproc. It (optionally) keeps partially downloaded files on system suspend and also do socksv5 bridging and more. On to the next task.

Cheers

/Joakim

Nice job!

I do a lot of downloads, but I haven’t looked into this before, but I can see how handy this would be.

Nail

Perhaps this could become part of the Corona library offering…?

can you share how to do that?