1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2025-07-23 17:19:47 +02:00

display photo

This commit is contained in:
lxsang
2021-01-05 19:12:35 +00:00
parent 9eb6d62d7d
commit 87169dd41f
6 changed files with 74 additions and 32 deletions

View File

@ -53,7 +53,8 @@ end
function IndexController:pdf(...)
local tmp_file = WWW_ROOT.."/cv_exported.pdf"
local cmd = "wkhtmltopdf "..HTTP_ROOT.."/"..self.registry.user.."/notoc "..tmp_file
local cmd = "wkhtmltopdf "..HTTP_ROOT.."/"..self.registry.user.."/index/notoc "..tmp_file
print(cmd)
local r = os.execute(cmd)
if r then
local mime = std.mimeOf(tmp_file)

View File

@ -15,3 +15,25 @@ function UserController:index(...)
self.template:set("data", data[1])
return true
end
function UserController:photo(...)
local data = self.user:findAll()
if not data or not data[1] then
self:error("Cannot fetch user info")
end
if(not data[1] or data[1].photo == "") then
self:error("User photo is not available")
end
local prefix = data[1].photo:match("%a+://")
local suffix = data[1].photo:gsub(prefix,"")
local path = string.format("/home/%s/", self.registry.user)..suffix
print(path)
if ulib.exists(path) then
local mime = std.mimeOf(path)
std.sendFile(path)
else
self:error("Asset file not found or access forbidden: "..path)
end
return false
end