liquid_feedback_frontend

annotate app/main/index/document_file.lua @ 1591:ad6048ec3432

Fixed document download
author bsw
date Sat Jan 30 11:39:33 2021 +0100 (2021-01-30)
parents 32cc544d5a5b
children
rev   line source
bsw@401 1 if not config.document_dir then
bsw/jbe@1309 2 return execute.view { module = "index", view = "404" }
bsw@401 3 end
bsw@401 4
bsw@401 5 local filename = param.get("filename")
bsw@401 6
bsw@1591 7 local file = io.open(encode.file_path(config.document_dir, filename))
bsw@1591 8
bsw@1591 9 if not file then
bsw@1591 10 return execute.view { module = "index", view = "404" }
bsw@1591 11 end
bsw@401 12
bsw@402 13 if param.get("inline") then
bsw@1591 14 request.add_header("Content-disposition", "inline; filename=" .. filename)
bsw@402 15 else
bsw@1591 16 request.add_header("Content-disposition", "attachment; filename=" .. filename)
bsw@402 17 end
bsw@1591 18
bsw@1591 19 local data = file:read("*a")
bsw@401 20
bsw@1591 21 slot.set_layout(nil, content_type)
bsw@1591 22 slot.put_into("data", data)
bsw@401 23

Impressum / About Us