From fb80b74de396c17207c2868d2c33b3b62b38d9fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=8B=87?= Date: Sun, 8 Aug 2021 18:50:54 +0800 Subject: [PATCH] add download image --- README.md | 21 +++++++++++++++++++++ download_image/download_image.lua | 7 +++++++ 2 files changed, 28 insertions(+) create mode 100644 download_image/download_image.lua diff --git a/README.md b/README.md index c8a252a..afcfbb3 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ * [1.图片上传](#1) * [2.图片拼接](#2) +* [4.图片下载](#3) ------ ## 前置安装 @@ -216,6 +217,26 @@ location /image_append { └── image_append.lua ``` +

3.图片下载

+- music-room配置 +```nginx configuration +# 子域名配置文件路径 +# /usr/local/openresty/nginx/conf.d/music-room.conf +# server contex 中添加location + +#Donwload image use ngx.exec +location /download_image2 { + content_by_lua_file /usr/local/openresty/nginx/conf/lua/download_image2.lua; +} +``` + +- 添加lua脚本 + +```bash +/usr/local/openresty/resty_funcs +. +└── download_image.lua +``` diff --git a/download_image/download_image.lua b/download_image/download_image.lua new file mode 100644 index 0000000..96b395b --- /dev/null +++ b/download_image/download_image.lua @@ -0,0 +1,7 @@ +-- Get download image id +local download_image_id = string.match(ngx.var.request_uri, ".*/(.*)$") +ngx.log(ngx.INFO , "Download image id: " .. download_image_id) + +-- Set redirect uri +local uri = "/internal_file_upload/" .. download_image_id .. ".jpg" +return ngx.exec(uri) \ No newline at end of file