[luci] using luci http library
Levente
leventelist at gmail.com
Thu Sep 7 16:54:51 CEST 2017
I'd like to use the LUCI's http protocol parser library in an OpenWRT
based system. What I want to achieve is to upload large files (10MB)
to the system.
I couldn't find any tutorial, only the API documentation.
So I have my naive test script which obviously doesn't work. I get
'502 Bad Gateway' error.
Can you please help me how to implement this?
#!/usr/bin/lua
http = require "luci.http"
proto = require "luci.http.protocol"
local fileOpened = 0
local fileP
function filecb(t, data, isLast)
if fileOpened == 0 then
FileP = io.open("/tmp/blabla", "wb")
fileOpened = 1
end
FileP:write(data)
if isLast then
io.close(FileP)
end
end
src = http.source()
httpMsg = proto.parse_message_header(src)
proto.parse_message_body(src, httpMsg, filecb)
http.close()
Any help is welcome.
Thank you,
Levente
More information about the luci
mailing list