Mercurial > prosody-modules
comparison mod_http_upload/mod_http_upload.lua @ 2472:595d6a25bd7a
mod_http_upload: Record upload slot metadata (fixes #718)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 29 Jan 2017 17:27:49 +0100 |
parents | f48e9e25aec4 |
children | 173fe999cc37 |
comparison
equal
deleted
inserted
replaced
2471:f48e9e25aec4 | 2472:595d6a25bd7a |
---|---|
11 local st = require"util.stanza"; | 11 local st = require"util.stanza"; |
12 local lfs = require"lfs"; | 12 local lfs = require"lfs"; |
13 local random_hex = require"util.uuid".get_nibbles; | 13 local random_hex = require"util.uuid".get_nibbles; |
14 local url = require "socket.url"; | 14 local url = require "socket.url"; |
15 local dataform = require "util.dataforms".new; | 15 local dataform = require "util.dataforms".new; |
16 local datamanager = require "util.datamanager"; | |
16 local t_concat = table.concat; | 17 local t_concat = table.concat; |
17 local t_insert = table.insert; | 18 local t_insert = table.insert; |
18 local s_upper = string.upper; | 19 local s_upper = string.upper; |
19 | 20 |
20 local function join_path(a, b) | 21 local function join_path(a, b) |
87 | 88 |
88 local random; | 89 local random; |
89 repeat random = random_hex(12); | 90 repeat random = random_hex(12); |
90 until lfs.mkdir(join_path(storage_path, random)) or not lfs.attributes(join_path(storage_path, random, filename)) | 91 until lfs.mkdir(join_path(storage_path, random)) or not lfs.attributes(join_path(storage_path, random, filename)) |
91 | 92 |
93 datamanager.list_apppend(origin.username, origin.host, module.name, { filename = join_path(storage_path, random, filename), size = filesize, time = os.time() }); | |
92 pending_slots[random.."/"..filename] = origin.full_jid; | 94 pending_slots[random.."/"..filename] = origin.full_jid; |
93 local base_url = module:http_url(); | 95 local base_url = module:http_url(); |
94 local slot_url = url.parse(base_url); | 96 local slot_url = url.parse(base_url); |
95 slot_url.path = url.parse_path(slot_url.path or "/"); | 97 slot_url.path = url.parse_path(slot_url.path or "/"); |
96 t_insert(slot_url.path, random); | 98 t_insert(slot_url.path, random); |