Comparison

mod_http_upload/mod_http_upload.lua @ 2665:cfb7936ff61f

mod_http_upload: Use the new util.id if available (in 0.10+)
author Kim Alvefur <zash@zash.se>
date Tue, 04 Apr 2017 00:06:19 +0200
parent 2651:2b741e68433b
child 2666:99c0b1bacdcd
comparison
equal deleted inserted replaced
2664:5b97b04e9d1b 2665:cfb7936ff61f
14 local dataform = require "util.dataforms".new; 14 local dataform = require "util.dataforms".new;
15 local datamanager = require "util.datamanager"; 15 local datamanager = require "util.datamanager";
16 local t_concat = table.concat; 16 local t_concat = table.concat;
17 local t_insert = table.insert; 17 local t_insert = table.insert;
18 local s_upper = string.upper; 18 local s_upper = string.upper;
19 local have_random, random = pcall(require, "util.random"); -- Only available in 0.10+ 19 local have_id, id = pcall(require, "util.id"); -- Only available in 0.10+
20 local uuid = require"util.uuid".generate; 20 local uuid = require"util.uuid".generate;
21 if have_random then 21 if have_id then
22 local b64 = require "util.encodings".base64.encode; 22 uuid = id.medium();
23 local b64url = { ['+'] = '-', ['/'] = '_', ['='] = '' };
24 function uuid()
25 return (b64(random.bytes(8)):gsub("[+/=]", b64url));
26 end
27 end 23 end
28 24
29 local function join_path(...) -- COMPAT util.path was added in 0.10 25 local function join_path(...) -- COMPAT util.path was added in 0.10
30 return table.concat({ ... }, package.config:sub(1,1)); 26 return table.concat({ ... }, package.config:sub(1,1));
31 end 27 end