Software /
code /
prosody-modules
Comparison
mod_http_upload/mod_http_upload.lua @ 2646:45ef16ebe565
mod_http_upload: Generate shorter directory names (closes #822)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 24 Mar 2017 01:07:54 +0100 |
parent | 2641:2d83e6c8160b |
child | 2647:d8487d5bd4fb |
comparison
equal
deleted
inserted
replaced
2645:cae371544ff5 | 2646:45ef16ebe565 |
---|---|
8 -- | 8 -- |
9 | 9 |
10 -- imports | 10 -- imports |
11 local st = require"util.stanza"; | 11 local st = require"util.stanza"; |
12 local lfs = require"lfs"; | 12 local lfs = require"lfs"; |
13 local uuid = require"util.uuid".generate; | |
14 local url = require "socket.url"; | 13 local url = require "socket.url"; |
15 local dataform = require "util.dataforms".new; | 14 local dataform = require "util.dataforms".new; |
16 local datamanager = require "util.datamanager"; | 15 local datamanager = require "util.datamanager"; |
17 local t_concat = table.concat; | 16 local t_concat = table.concat; |
18 local t_insert = table.insert; | 17 local t_insert = table.insert; |
19 local s_upper = string.upper; | 18 local s_upper = string.upper; |
20 | 19 local have_random, random = pcall(require, "util.random"); -- Only available in 0.10+ |
21 local function join_path(...) | 20 local uuid = require"util.uuid".generate; |
21 if have_random then | |
22 local b64 = require "util.encodings".base64; | |
23 local b64url = { ['+'] = '-', ['/'] = '_', ['='] = '' }; | |
24 function uuid() | |
25 return (b64(random(8)):gsub("[+/=]", b64url)); | |
26 end | |
27 end | |
28 | |
29 local function join_path(...) -- COMPAT util.path was added in 0.10 | |
22 return table.concat({ ... }, package.config:sub(1,1)); | 30 return table.concat({ ... }, package.config:sub(1,1)); |
23 end | 31 end |
24 | 32 |
25 -- config | 33 -- config |
26 local file_size_limit = module:get_option_number(module.name .. "_file_size_limit", 1024 * 1024); -- 1 MB | 34 local file_size_limit = module:get_option_number(module.name .. "_file_size_limit", 1024 * 1024); -- 1 MB |