Create a gist now

Instantly share code, notes, and snippets.

send_image.lua
local image_path = ngx.var.image_path
local images_dir = "/home/koheyhey/localdata/" -- where images come from
local function return_not_found(msg)
ngx.status = ngx.HTTP_NOT_FOUND
ngx.header["Content-type"] = "text/html"
ngx.say(msg or "not found")
ngx.exit(0)
end
local source_fname = "/home/koheyhey/localdata/"..image_path
-- make sure the file exists
local file = io.open(source_fname)
if not file then
return_not_found(msg)
end
input_file_stream = file:read("*a")
ngx.say(input_file_stream)
file:close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment