liquid_feedback_frontend

changeset 1591:ad6048ec3432

Fixed document download
author bsw
date Sat Jan 30 11:39:33 2021 +0100 (2021-01-30)
parents 8b3375b7f590
children e647e6643c2f
files app/main/index/document_file.lua
line diff
     1.1 --- a/app/main/index/document_file.lua	Wed Jan 27 10:07:05 2021 +0100
     1.2 +++ b/app/main/index/document_file.lua	Sat Jan 30 11:39:33 2021 +0100
     1.3 @@ -4,15 +4,20 @@
     1.4  
     1.5  local filename = param.get("filename")
     1.6  
     1.7 -local file = assert(io.open(encode.file_path(config.document_dir, filename)), "file not found")
     1.8 +local file = io.open(encode.file_path(config.document_dir, filename))
     1.9 +
    1.10 +if not file then
    1.11 +  return execute.view { module = "index", view = "404" }
    1.12 +end
    1.13  
    1.14  if param.get("inline") then
    1.15 -  print('Content-disposition: inline; filename=' .. filename)
    1.16 +  request.add_header("Content-disposition", "inline; filename=" .. filename)
    1.17  else
    1.18 -  print('Content-disposition: attachment; filename=' .. filename)
    1.19 +  request.add_header("Content-disposition", "attachment; filename=" .. filename)
    1.20  end
    1.21 -print('')
    1.22 +
    1.23 +local data = file:read("*a")
    1.24  
    1.25 -io.stdout:write(file:read("*a"))
    1.26 +slot.set_layout(nil, content_type)
    1.27 +slot.put_into("data", data)
    1.28  
    1.29 -exit()

Impressum / About Us