Current Lua downloadable firmware will be posted here

User avatar
By ma.ag37
#52855 I have an image on the module but I am unable to get it successfully delivered to the connected clients on the webpage.

I use the following code:

if received_request == "smarty_home.jpg " then
print("image request received\n")
file.open("smarty_home.jpg")
print("image_opened\n")

nextline = file.read(1400)
while nextline do
client:send(nextline)
nextline = file.read(1400)
end
file.close()
print ("image_sent\n")

end

But I get only a portion of image at the client on the webpage

Please Help
User avatar
By devsaurus
#52859 The client:send() function is asynchronous, i.e. it will return to your Lua code before the payload is actually sent to the client. In worst case data is overwritten in the internal network buffers which yields the results you observed.
You'd need to restructure your code in a way that consecutive chunks are sent from the sent-callback. Refer to http://nodemcu.readthedocs.io/en/latest ... /net/#note