精华内容
下载资源
问答
  • LUA上传文件

    2019-09-24 08:15:01
    开发的作者是:Yichun "agentzh" Zhang (章亦春)... 文件在:https://github.com/agentzh/lua-resty-upload ---------------------------------------------------------------------------------------- 废...

    开发的作者是:Yichun "agentzh" Zhang (章亦春) agentzh@gmail.com

    文件在:https://github.com/agentzh/lua-resty-upload

    ----------------------------------------------------------------------------------------

    废话少说,具体步骤如下:

    1、上传upload.lua到指定的目录,我的是_services/upload/conf

    2、配置上传的SERVER(域名自己配制)

    location = /upload {
        client_max_body_size    512k;
        
        content_by_lua '
            ngx.header["Content-Type"] = "text/plain"
            local upload = require("_service.upload.lib.upload")
            local cjson = require "cjson"
    
            local form = upload:new(512*1024*1024)
    
            form:set_timeout(2000) -- 1 sec
    
            while true do
                local typ, res, err = form:read()
                if not typ then
                    ngx.say("failed to read: ", err)
                    return
                end
                if (typ=="body") then
                    ngx.say(res)
                end
                if typ == "eof" then
                    break
                end
            end
    
            local typ, res, err = form:read()
            --ngx.say("read: ", cjson.encode({typ, res}))
        ';
    }

    3、HTML文件内容

    <html><head>
    <title>上载文件表单</title></head>
    <body>
    <form enctype="multipart/form-data" action="http://***.com:7662/upload" method="post">
    请选择文件:<br>
    <input name="upload_file" type="file"><br>
    <input type="submit" value="上传文件">
    </form>
    </body>
    </html>

    4、测试

    显示图片

     

    转载于:https://www.cnblogs.com/liqiu/archive/2013/05/21/3090431.html

    展开全文
  • nginx lua上传文件

    千次阅读 2018-03-15 19:23:52
    为了方便上传文件到嵌入式设备,特地借用嵌入式原有nginx环境,添加lua文件上传功能。ps:因为lua轻量体积小可控,所以选lua喽。代码如下:upload.lua-- Copyright (C) Yichun Zhang (agentzh) -- local sub = ...

    为了方便上传文件到嵌入式设备,特地借用嵌入式原有nginx环境,添加lua文件上传功能。

    ps:因为lua轻量体积小可控,所以选lua喽。

    代码如下:

    upload.lua

    -- Copyright (C) Yichun Zhang (agentzh)
    
    
    -- local sub = string.sub
    local req_socket = ngx.req.socket
    local match = string.match
    local setmetatable = setmetatable
    local type = type
    local ngx_var = ngx.var
    -- local print = print
    
    
    local _M = { _VERSION = '0.10' }
    
    
    local CHUNK_SIZE = 4096
    local MAX_LINE_SIZE = 512
    
    local STATE_BEGIN = 1
    local STATE_READING_HEADER = 2
    local STATE_READING_BODY = 3
    local STATE_EOF = 4
    
    
    local mt = { __index = _M }
    
    local state_handlers
    
    
    local function get_boundary()
        local header = ngx_var.content_type
        if not header then
            return nil
        end
    
        if type(header) == "table" then
            header = header[1]
        end
    
        local m = match(header, ";%s*boundary=\"([^\"]+)\"")
        if m then
            return m
        end
    
        return match(header, ";%s*boundary=([^\",;]+)")
    end
    
    
    function _M.new(self, chunk_size, max_line_size)
        local boundary = get_boundary()
    
        -- print("boundary: ", boundary)
    
        if not boundary then
            return nil, "no boundary defined in Content-Type"
        end
    
        -- print('boundary: "', boundary, '"')
    
        local sock, err = req_socket()
        if not sock then
            return nil, err
        end
    
        local read2boundary, err = sock:receiveuntil("--" .. boundary)
        if not read2boundary then
            return nil, err
        end
    
        local read_line, err = sock:receiveuntil("\r\n")
        if not read_line then
            return nil, err
        end
    
        return setmetatable({
            sock = sock,
            size = chunk_size or CHUNK_SIZE,
            line_size = max_line_size or MAX_LINE_SIZE,
            read2boundary = read2boundary,
            read_line = read_line,
            boundary = boundary,
            state = STATE_BEGIN
        }, mt)
    end
    
    
    function _M.set_timeout(self, timeout)
        local sock = self.sock
        if not sock then
            return nil, "not initialized"
        end
    
        return sock:settimeout(timeout)
    end
    
    
    local function discard_line(self)
        local read_line = self.read_line
    
        local line, err = read_line(self.line_size)
        if not line then
            return nil, err
        end
    
        local dummy, err = read_line(1)
        if dummy then
            return nil, "line too long: " .. line .. dummy .. "..."
        end
    
        if err then
            return nil, err
        end
    
        return 1
    end
    
    
    local function discard_rest(self)
        local sock = self.sock
        local size = self.size
    
        while true do
            local dummy, err = sock:receive(size)
            if err and err ~= 'closed' then
                return nil, err
            end
    
            if not dummy then
                return 1
            end
        end
    end
    
    
    local function read_body_part(self)
        local read2boundary = self.read2boundary
    
        local chunk, err = read2boundary(self.size)
        if err then
            return nil, nil, err
        end
    
        if not chunk then
            local sock = self.sock
    
            local data = sock:receive(2)
            if data == "--" then
                local ok, err = discard_rest(self)
                if not ok then
                    return nil, nil, err
                end
    
                self.state = STATE_EOF
                return "part_end"
            end
    
            if data ~= "\r\n" then
                local ok, err = discard_line(self)
                if not ok then
                    return nil, nil, err
                end
            end
    
            self.state = STATE_READING_HEADER
            return "part_end"
        end
    
        return "body", chunk
    end
    
    
    local function read_header(self)
        local read_line = self.read_line
    
        local line, err = read_line(self.line_size)
        if err then
            return nil, nil, err
        end
    
        local dummy, err = read_line(1)
        if dummy then
            return nil, nil, "line too long: " .. line .. dummy .. "..."
        end
    
        if err then
            return nil, nil, err
        end
    
        -- print("read line: ", line)
    
        if line == "" then
            -- after the last header
            self.state = STATE_READING_BODY
            return read_body_part(self)
        end
    
        local key, value = match(line, "([^: \t]+)%s*:%s*(.+)")
        if not key then
            return 'header', line
        end
    
        return 'header', {key, value, line}
    end
    
    
    local function eof()
        return "eof", nil
    end
    
    
    function _M.read(self)
        -- local size = self.size
    
        local handler = state_handlers[self.state]
        if handler then
            return handler(self)
        end
    
        return nil, nil, "bad state: " .. self.state
    end
    
    
    local function read_preamble(self)
        local sock = self.sock
        if not sock then
            return nil, nil, "not initialized"
        end
    
        local size = self.size
        local read2boundary = self.read2boundary
    
        while true do
            local preamble = read2boundary(size)
            if not preamble then
                break
            end
    
            -- discard the preamble data chunk
            -- print("read preamble: ", preamble)
        end
    
        local ok, err = discard_line(self)
        if not ok then
            return nil, nil, err
        end
    
        local read2boundary, err = sock:receiveuntil("\r\n--" .. self.boundary)
        if not read2boundary then
            return nil, nil, err
        end
    
        self.read2boundary = read2boundary
    
        self.state = STATE_READING_HEADER
        return read_header(self)
    end
    
    
    state_handlers = {
        read_preamble,
        read_header,
        read_body_part,
        eof
    }
    
    
    return _M

    Download.lua

    local upload = require "./upload"
    local UPLOAD_ROOT_PATH = "/mnt/sdcard/upload/"
    --local UPLOAD_ROOT_PATH = "/data/upload/"
    
    function split(s, delim)
      if type(delim) ~= "string" or string.len(delim) <= 0 then
        return
      end
     
      local start = 1
      local t = {}
      while true do
      local pos = string.find (s, delim, start, true) -- plain find
        if not pos then
         break
        end
     
        table.insert (t, string.sub (s, start, pos - 1))
        start = pos + string.len (delim)
      end
      table.insert (t, string.sub (s, start))
     
      return t
    end
    
    function trim(s)
    	return (s:gsub("^%s*(.-)%s*$", "%1"))
    end
    
    function get_filename(res)  
        local filename = ngx.re.match(res,'(.+)filename="(.+)"(.*)')  
        if filename then   
            return filename[2]  
        end  
    end
    
    function DownLoad()
    
        local chunk_size = 4096
        local form,err=upload:new(chunk_size)
        if not form then
             ngx.log(ngx.ERR, "failed to new upload: ", err)
             ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
        end 
    
        form:set_timeout(100000)
    
        while true do
            local typ,res,err=form:read()
            if not typ then
                ErrorMsg="failed to read :"..err
                return 1
            end
    
            if typ =="header" then
                local key=res[1]
                local value=res[2]
                if key =="Content-Disposition" then
                    local kvlist= split(value,';')
                     for _, kv in ipairs(kvlist) do
                        local seg = trim(kv)
                        if seg:find("filename") then
                            local kvfile = split(seg, "=")
                            filename = string.sub(kvfile[2],2,-2);
                            if filename then
                                local linuxTime=tostring(os.time())
                                filePath=UPLOAD_ROOT_PATH .."/" ..linuxTime.."_"..filename
                                fileToSave,errmsg = io.open(filePath, "w+")
                                --存储的文件路径                    
                                if not fileToSave then
                                    ErrorMsg="failed to open file "..filePath .. errmsg
                                    return 2
                                end
                            else
                                ErrorMsg="filename cann't find"
                                return 3
                            end
                            --跳出循环
                            break 
                        end
                    end
                end
            elseif typ =="body" then
                if fileToSave then
                   fileToSave:write(res)
                end
            elseif typ =="part_end" then
                if fileToSave then
                   fileToSave:close()
                   fileToSave = nil
                end
            elseif typ =="eof" then
    			break;
            else
                ngx.log(ngx.INFO, "do other things")
            end
        end
        return 0
    end
    
    local ret = DownLoad();
    if ret == 200 or ret == 0 then
    	ngx.header['Content-Type'] = 'application/json; charset=utf-8'
    	ngx.say("{code:success}");
    else
    	ngx.header['Content-Type'] = 'application/json; charset=utf-8'
    	ngx.say("{code:" .. ret .. "}");
    end

    upload.html

    <!DOCTYPE html>
    <html>
        <head>
             <title>File upload example</title>
        </head>
        <body>
               <form action="/Download" method="post" enctype="multipart/form-data">
               <input type="file" name="testFileName"/>
               <input type="submit" name="upload" value="Upload" />
               </form>
        </body>
    </html>

    lua.conf

    server {
    	listen 8080;
    	client_max_body_size 100m;
    	client_body_buffer_size 512k;
    	
    	server_name  localhost;
    	
    	location / {
    		root /mnt/sdcard/;
    		autoindex on;
    		autoindex_exact_size off;
    		autoindex_localtime on;
    	}
    	
    	root /mnt/sdcard/lua/;
    	
    	location /Download  
    	{  
    		content_by_lua_file $document_root/Download.lua;
    	}
    }


    nginx编译参数

    #luajit
    tar -xzvf LuaJIT-2.0.4.tar.gz
    cd LuaJIT-2.0.4
    make PREFIX=/usr/local/luajit
    sudo make install PREFIX=/usr/local/luajit
    make clean
    mv /usr/local/luajit/lib/libluajit-5.1.so /usr/local/luajit/lib/libluajit-5.1.so.bak
    cd ..
    rm -rf LuaJIT-2.0.4
    
    
    #nginx
    tar -xzvf nginx-1.10.2.tar.gz
    cd nginx-1.10.2
    export LUAJIT_LIB=/usr/local/luajit/lib
    export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0
    ./configure --prefix=/usr/local/nginx \
    --with-http_ssl_module \
    --with-http_stub_status_module \
    --with-http_v2_module \
    --with-ipv6 \
    --with-http_gzip_static_module \
    --with-http_realip_module \
    --with-http_flv_module \
    --with-pcre-jit \
    --add-module=/data/source/nginx-rtmp-module \
    --add-module=/data/source/lua-nginx-module \
    --add-module=/data/source/echo-nginx-module  \
    --user=www --group=www
    make
    sudo make install
    make clean
    cd ..
    rm -rf nginx-1.10.2

    luajit跨平台编译脚本参考

    #luajit
    wget http://luajit.org/download/LuaJIT-2.0.4.tar.gz
    
    #luajit
    tar -xzvf LuaJIT-2.0.4.tar.gz
    cd LuaJIT-2.0.4
    make clean
    
    #PREFIX=$HTTP_DIR/install/luajit/
    #PREFIX=/datadisk/ee/ac/20170503_product/misc/app/http+rtsp/http/install/luajit/
    
    make PREFIX=/datadisk/ee/ac/20170503_product/misc/app/http+rtsp/http/install/luajit/ HOST_CC="gcc -m32" \
    CROSS=/datadisk/ee/ac/20170503_product/rk1108/prebuilts/toolschain/usr/bin/arm-linux-
    
    make PREFIX=/datadisk/ee/ac/20170503_product/misc/app/http+rtsp/http/install/luajit/ HOST_CC="gcc -m32" install
    
    make clean
    #mv /usr/local/luajit/lib/libluajit-5.1.so /usr/local/luajit/lib/libluajit-5.1.so.bak
    cd ..
    rm -rf LuaJIT-2.0.4


    展开全文
  • 解决nginx + lua 上传文件问题

    千次阅读 2015-10-30 11:57:46
    本文的原文连接是: ... 未经博主允许不得转载。 博主地址是: ... 1,首先不能创建upload对象 ...因为之前使用过一个叫 lua_need_request_body 显示 respons的post信息,和...lua+nginx上传速度还是非常快的。而且很轻量。

    本文的原文连接是: http://blog.csdn.net/freewebsys/article/details/49509123 未经博主允许不得转载。
    博主地址是:http://blog.csdn.net/freewebsys

    1,首先不能创建upload对象

    直接报错

    failed to new upload: request body already exists

    参考这个博客:
    http://my.oschina.net/timingbob/blog/164231
    就是request body 不能被使用2次造成的。

    因为之前使用过一个叫 lua_need_request_body 显示 respons的post信息,和这个冲突了。去掉就好了。

    这个博客上面有详细写,如何将post信息写到日志里面。
    http://blog.csdn.net/jom_ch/article/details/15359129

    去掉就好了。

    2,将上传日志写到磁盘

    参考:http://blog.csdn.net/langeldep/article/details/9628819
    上面已经写的很详细了。

    package.path = '/usr/local/share/lua/5.1/?.lua;/usr/local/openresty/lualib/resty/?.lua;'
    package.cpath = '/usr/local/lib/lua/5.1/?.so;'
    
    local upload = require "upload"
    
    local chunk_size = 4096  --如果不设置默认是4096.
    local form = upload:new(chunk_size)
    local file
    local filelen=0
    form:set_timeout(0) -- 1 sec
    local filename
    
    function get_filename(res)
        local filename = ngx.re.match(res,'(.+)filename="(.+)"(.*)')
        if filename then 
            return filename[2]
        end
    end
    
    local osfilepath = "/usr/local/openresty/nginx/html/"
    local i=0
    while true do
        local typ, res, err = form:read()
        if not typ then
            ngx.say("failed to read: ", err)
            return
        end
        if typ == "header" then
            if res[1] ~= "Content-Type" then
                filename = get_filename(res[2])
                if filename then
                    i=i+1
                    filepath = osfilepath  .. filename
                    file = io.open(filepath,"w+")
                    if not file then
                        ngx.say("failed to open file ")
                        return
                    end
                else
                end
            end
        elseif typ == "body" then
            if file then
                filelen= filelen + tonumber(string.len(res))    
                file:write(res)
            else
            end
        elseif typ == "part_end" then
            if file then
                file:close()
                file = nil
                ngx.say("file upload success")
            end
        elseif typ == "eof" then
            break
        else
        end
    end
    if i==0 then
        ngx.say("please upload at least one file!")
        return
    end
    

    这里需要注意一个问题,
    /usr/local/openresty/nginx/html/文件夹必须是nobody权限,否则不能写文件,报错。

    chown nobody:nobody /usr/local/openresty/nginx/html

    上传啥都行了,也可以是图片,文件。

    3,总结

    本文的原文连接是: http://blog.csdn.net/freewebsys/article/details/49509123 未经博主允许不得转载。
    博主地址是:http://blog.csdn.net/freewebsys

    lua+nginx上传速度还是非常快的。而且很轻量。

    展开全文
  • 主要介绍了nginx+lua搭建文件上传下载服务,涉及到nginx安装配置方法,本文通过代码给大家介绍的非常详细,需要的朋友可以参考下
  • 【1】openresty上传upload源码库 Github:...源码文件upload.lua文件 【2】上传 代码如下,详见注释: 1 local upload = require "resty.upload" 2 local cjson = require "cjson" 3...

    【1】openresty 上传upload源码库

    Github:https://github.com/openresty/lua-resty-upload

    源码文件upload.lua文件

    【2】上传

    代码如下,详见注释:

      1 local upload = require "resty.upload"
      2 local cjson = require "cjson"
      3 
      4 -- test.sh 
      5 -- curl -F "filename=@/home/test/test.wav" "http://127.0.0.1/uploadfile.gss?filename=test.wav&&type=wav&&billingcode=87654321"
      6 
      7 local response = {["code"] = 200, ["msg"] = "upload success!"} 
      8 
      9 local args = ngx.req.get_uri_args()
     10 if not args then
     11     ngx.exit(ngx.HTTP_BAD_REQUEST)
     12 end
     13 
     14 local filename = args["filename"] or "noname.file"
     15 local billingcode = args["billingcode"]
     16 local filetype = args["type"]
     17 
     18 -- 判断文件类型
     19 local res, err = ngx.re.match(filename, [[\.(?:xml|wav|ext)$]])
     20 if not res then
     21     response.code = 401
     22     response.msg = "only xml or wav or ext format file can upload"
     23     ngx.say(cjson.encode(response))
     24     return
     25 end
     26 
     27 if err then
     28     ngx.log(ngx.ERR, "match err:", err)
     29     ngx.exit(ngx.HTTP_BAD_REQUEST)
     30 end
     31 
     32 -- 保存文件根目录
     33 local save_file_root = "/home/kaizenly/"
     34 
     35 local save_file_dir = save_file_root
     36 
     37 -- 创建各类文件的保存目录[wav/ext/app]
     38 if "wav" == filetype or "ext" == filetype then
     39     save_file_dir = save_file_dir .. filetype
     40 elseif "flow" == filetype or "state" == filetype then
     41     save_file_dir = save_file_dir .. "app" 
     42 else
     43     response.code = 402
     44     response.msg = "error file type! filetype: " .. filetype
     45     ngx.say(cjson.encode(response))
     46     return
     47 end
     48 
     49 local dfile = io.open(save_file_dir, "rb")
     50 if dfile then
     51     dfile:close()
     52 else
     53     local md = "mkdir "
     54     local mdpath = md .. save_file_dir
     55     os.execute(mdpath)
     56     ngx.log(ngx.ERR, "create save file first dir: " .. mdpath)
     57 end
     58 
     59 save_file_dir = save_file_dir .. "/"
     60 
     61 -- 创建各类文件的保存子目录[按billingcode存储]
     62 local save_file_path = ''
     63 
     64 if "wav" == filetype or "ext" == filetype then
     65     save_file_path = save_file_dir .. billingcode
     66 else
     67     save_file_path = save_file_dir .. filetype .. "xml" 
     68 end
     69 
     70 local dfile = io.open(save_file_path, "rb")
     71 if dfile then 
     72     dfile:close()
     73 else
     74     local md = "mkdir "
     75     local mdpath = md .. save_file_path
     76     os.execute(mdpath)
     77     ngx.log(ngx.ERR, "create save file second dir: " .. mdpath)
     78 end
     79 
     80 save_file_path = save_file_path .. "/"
     81 
     82 -- 创建上传form
     83 local chunk_size = 8192 -- should be set to 4096 or 8192
     84 
     85 local form, err = upload:new(chunk_size)
     86 if not form then
     87     ngx.log(ngx.ERR, "failed to new upload: ", err)
     88     ngx.exit(500)
     89 end
     90 
     91 form:set_timeout(1000) -- 1 sec
     92 
     93 local function close_file(write_file)
     94     if io.type(write_file) == "file" then  -- write_file处于打开状态,则关闭文件。
     95         write_file:close()
     96         write_file = nil
     97     end
     98 end
     99 
    100 -- 上传过程
    101 local write_file -- 文件句柄
    102 while true do
    103     local typ, recv, err = form:read()
    104     if not typ then
    105         response.code = 403
    106         -- ngx.say("failed to read file: ", err)
    107         response.msg = "failed to read file"
    108         break
    109     end
    110 
    111     if typ == "header" and "file" ~= io.type(write_file) then
    112         write_file, err = io.open(save_file_path .. filename, 'wb+')
    113         if err then
    114             ngx.log(ngx.ERR, "failed create hd:", err)
    115             response.code = 404
    116             response.msg = "failed create file:" .. err
    117             break
    118         end
    119     elseif typ == "body" and "file" == io.type(write_file) then
    120         write_file:write(recv)
    121     elseif typ == "part_end" then
    122         close_file(write_file)
    123     elseif typ == "eof" then
    124         response.code = 200 
    125         response.msg = "upload success"
    126         break
    127     end
    128 end
    129 
    130 ngx.say(cjson.encode(response))

    如上代码。

    【3】删除

    代码如下,详见注释:

     1 local upload = require "resty.upload"
     2 local cjson = require "cjson"
     3 
     4 local args = ngx.req.get_uri_args()
     5 if not args then
     6     ngx.exit(ngx.HTTP_BAD_REQUEST)
     7 end
     8 
     9 local filename = args["filename"] or "noname.file"
    10 local billingcode = args["billingcode"] or ""
    11 local filetype = args["type"]
    12 
    13 local response = {["code"] = 200, ["msg"] = "remove success!"} 
    14 
    15 -- 判断文件类型
    16 local res, err = ngx.re.match(filename, [[\.(?:xml|wav|ext)$]])
    17 if not res then
    18     response.code = 401
    19     response.msg = "only xml or wav or ext format file can remove"
    20     ngx.say(cjson.encode(response))
    21     return
    22 end
    23 
    24 if err then
    25     ngx.log(ngx.ERR, "match err:", err)
    26     ngx.exit(ngx.HTTP_BAD_REQUEST)
    27 end
    28 
    29 -- 保存文件根目录
    30 local save_file_root = "/home/kaizenly/"
    31 
    32 -- 确定删除文件路径
    33 local remove_file_path = ''
    34 if "wav" == filetype or "ext" == filetype then
    35     remove_file_path = save_file_root .. filetype
    36     if "" ~= billingcode then
    37         remove_file_path = remove_file_path .. "/" .. billingcode
    38     end
    39 elseif "flow" == filetype or "state" == filetype then
    40     remove_file_path = save_file_root .. "app/" .. filetype .. "xml"
    41 else
    42     response.code = 402
    43     response.msg = "failed to remove, error file type!"
    44     ngx.say(cjson.encode(response))
    45     return
    46 end
    47 
    48 remove_file  = remove_file_path .. "/" .. filename
    49 
    50 -- 判断删除文件是否存在
    51 local dfile = io.open(remove_file, "rb")
    52 if dfile then
    53     dfile:close()
    54 else
    55     response.code = 403
    56     response.msg = "the remove file is not exist!"
    57     ngx.say(cjson.encode(response))
    58     return
    59 end
    60 
    61 -- 执行删除
    62 local res, err = os.remove(remove_file)
    63 if not res then
    64     response.code = 404
    65     response.msg = "failed to remove " .. remove_file .. ", err: " .. (err or '')
    66 else
    67    ngx.log(ngx.ERR, "success to remove file: " .. remove_file)
    68    -- 如果目录为空,删除目录
    69    local cmd = "ls " .. remove_file_path
    70    local s = io.popen(cmd)
    71    local file_lists = s:read("*all")
    72    if #file_lists == 0 then
    73       ngx.log(ngx.ERR, "success to remove file second dir: " .. remove_file_path)
    74       os.remove(remove_file_path)
    75    end
    76 end
    77 
    78 ngx.say(cjson.encode(response))

    如上代码

    Good Good Study, Day Day Up.

    顺序 选择 循环 总结

    转载于:https://www.cnblogs.com/Braveliu/p/10674395.html

    展开全文
  • nginx+lua搭建文件上传下载服务

    千次阅读 2017-04-11 19:03:22
    项目需要做一个文件上传下载服务,利用nginx+lua 做一个代理服务,上传入口统一,分发到不同的机器存储,下载链接和物理存储隔离,支持添加agent的方式扩容,这里主要讲一下思路和搭建配置过程,大神勿喷。
  • 本文主要是介绍一种基于Openresty和Lua实现的文件上传服务器 第一步 配置openresty里面的nginx.conf http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; ...
  • 收录待用,修改转载已取得腾讯云授权 最新腾讯云技术公开课...项目需要做一个文件上传下载服务,利用 nginx+lua 做一个代理服务,上传入口统一,分发到不同的机器存储,下载链接和物理存储隔离,支持添加 agent...
  • 可能要用到以下的库文件 1、安装nginx1.18 下载http://nginx.org/en/download.html解压tar -xvfnginx-1.18.tar.gz 2、安装LuaJIT-2.0.4(轻量级lua)http://luajit.org/download.html 修改makefile 里面的安装...
  • Lua文件操作自定义上传头像

    千次阅读 2016-03-22 17:15:31
    先简单介绍一下被迫使用Lua的IO的情境: 游戏支持玩家自定义上传头像,在排行榜中会显示玩家列表(包括本服、跨服),原有的做法是先检测CCUserDefault中是否存在指定图片的key以及它的状态。然后在下载头像、下载...
  • Nginx+upload+lua实现简单文件上传服务
  • nginx+lua 做一个代理服务,上传入口统一,分发到不同的机器存储,下载链接和物理存储隔离,支持添加 agent 的方式扩容,这里主要讲一下思路和搭建配置过程,大神勿喷。 主要逻辑 上传 前端...
  • NodeMCU-Tool, 在NodeMCU上,上传 管理Lua文件 nodemcu工具将Lua文件上传/下载到你的esp8266/esp32模块,带有NodeMCU固件。简单的命令行 。跨平台文件管理。 NodeMCU 。$ npm install nodemcu-tool -g
  • --文件类型 if res ~= nil then ngx.say( "" ..res[ 2 ]) if string .match(res[ 2 ], 'image/' ) == nil then ngx.say( "only support image" ) return end end end elseif typ == ...
  • Lua文件操作

    2015-07-22 22:22:00
    先简单介绍一下被迫使用Lua的IO的情境: 游戏支持玩家自定义上传头像,在排行榜中会显示玩家列表(包括本服、跨服),原有的做法是先检测CCUserDefault中是否存在指定图片的key以及它的状态。然后在下载头像、下载...
  • 前言 最近刚刚实现的文件服务中心,记录一下,为没做过的人提供一下... 远程访问 实现上传下载 图片添加水印 feign远程调用解决MultipartFile为null的问题 搭建openoffice-实现文件预览 自定义openoffice连接池 1.文...
  • Lua文件操作 先简单介绍一下被迫使用Lua的IO的情境: 游戏支持玩家自定义上传头像,在排行榜中会显示玩家列表(包括本服、跨服),原有的做法是先检测CCUserDefault中是否存在指定图片的key以及它的...

空空如也

空空如也

1 2 3 4 5 ... 12
收藏数 221
精华内容 88
关键字:

lua上传文件