Here is a simple wget function for esp8266 nodemcu lua, which gets a remote file and saves it locally. Your esp8266 has to have the http and file module included in its firmware.
https://nodemcu.readthedocs.io/en/ma.../modules/http/
https://nodemcu.readthedocs.io/en/master/en/modules/file/
here is the function:
usage:
the usage example shows how to get contents of external file.txt and save the contents to the local_file_name.lua
https://nodemcu.readthedocs.io/en/ma.../modules/http/
https://nodemcu.readthedocs.io/en/master/en/modules/file/
here is the function:
Code:
function wget(url,file_name)
http.get(url, nil, function(code, data)
if (code < 0) then
print("HTTP request failed")
else
-- print(code, data)
-- open file in 'w' mode
if file.open(file_name, "w") then
-- write text to the file
file.write(data)
file.close()
end
end
end)
end
Code:
wget("http://example.com/file.txt", "local_file_name.lua")
