3 nixio = require "nixio"
4 fs = require "nixio.fs"
5 util = require "luci.util"
6 ltn12 = require "ltn12"
7 luafm = require "luafm"
11 for dummy,param in pairs(util.split(nixio.getenv('QUERY_STRING'),'&')) do
12 val = util.split(param,'=')
13 args[val[1]] = util.urldecode(val[2],true)
16 path = luafm.make_path(args["path"])
18 file = io.open(path,"rb")
24 print("Content-Type: application/octet-stream")
25 print('Content-Disposition: attachment; filename="'..fs.basename(args["path"])..'"')
28 ltn12.source.file(file),
29 ltn12.sink.file(io.stdout)
32 print("Status: 404 Not Found")
33 print("Content-Type: text/plain")
35 print("File not found")