liquid_feedback_frontend
view app/main/index/document_file.lua @ 1840:5775300b81d6
Added tag v4.0.0 for changeset 3be240de942b
author | jbe |
---|---|
date | Wed Apr 28 13:30:18 2021 +0200 (2021-04-28) |
parents | ad6048ec3432 |
children |
line source
1 if not config.document_dir then
2 return execute.view { module = "index", view = "404" }
3 end
5 local filename = param.get("filename")
7 local file = io.open(encode.file_path(config.document_dir, filename))
9 if not file then
10 return execute.view { module = "index", view = "404" }
11 end
13 if param.get("inline") then
14 request.add_header("Content-disposition", "inline; filename=" .. filename)
15 else
16 request.add_header("Content-disposition", "attachment; filename=" .. filename)
17 end
19 local data = file:read("*a")
21 slot.set_layout(nil, content_type)
22 slot.put_into("data", data)