Let me introduce my new file download tool.
It uses feature of HTTP protocol named a 'byte serving'. Script checks that server is able to split data and gets target file by 1024 byte chunks that is fittable for file routines.
Please take a look on the tool and point me on issues: https://github.com/grytole/iot/blob/master/nodemcu-sketches/wget.lua
Some pros:
- file size independent = can use all available memory if file system can handle it (new 1.5.4.1 nodemcu release has no file size limit, hooray!) ;
- it looks stable now = I can't crash tool now, but I've not tried hard;
- supports HTTPS = you can get scripts directly from github (but I'm pretty sure your firmware needs SSL support);
- destination file name can be changed = just a simple pleasures;
- it fast = download works muuuuch faster than default 115200 serial connection;
Some cons:
- tool can not handle all variety of targets = e.g. github by default has huge response headers at start of data, so it fills out all space in TCP packet and lefts no space for important headers (damn, github, move your junk to the end!), but everything works fine with raw links - just press 'raw' button on the file page and use "...raw.githubusercontent.com..." URLs;
- takes a lot of heap = I'm not sure but it can be up to 20k;
- can not handle redirects = if server responds with code 302 it just stops (but it is done before download action) [in near TODO state for me];
- no additional options = it can not overwrite existing file, it can not continue download of uncompleted file [in far TODO state for me];
Some screenshots: