liquid_feedback_frontend
annotate app/main/index/download_file.lua @ 1546:ae194d0235c2
Set session cookie only if session is needed
| author | bsw | 
|---|---|
| date | Thu Oct 22 11:57:23 2020 +0200 (2020-10-22) | 
| parents | 32cc544d5a5b | 
| children | 
| rev | line source | 
|---|---|
| bsw/jbe@6 | 1 if not config.download_dir then | 
| bsw/jbe@1309 | 2 return execute.view { module = "index", view = "404" } | 
| bsw/jbe@6 | 3 end | 
| bsw/jbe@6 | 4 | 
| bsw/jbe@6 | 5 local filename = param.get("filename") | 
| bsw/jbe@6 | 6 | 
| bsw/jbe@6 | 7 local file = assert(io.open(encode.file_path(config.download_dir, filename)), "file not found") | 
| bsw/jbe@6 | 8 | 
| bsw/jbe@6 | 9 print('Content-type: application/octet-stream') | 
| bsw/jbe@6 | 10 print('Content-disposition: attachment; filename=' .. filename) | 
| bsw/jbe@6 | 11 print('') | 
| bsw/jbe@6 | 12 | 
| bsw/jbe@6 | 13 io.stdout:write(file:read("*a")) | 
| bsw/jbe@6 | 14 | 
| bsw/jbe@6 | 15 exit() |