Mercurial > prosody-modules
comparison mod_http_upload/mod_http_upload.lua @ 2489:9d154c929319
mod_http_upload: Log the directory and filename joined
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 10 Feb 2017 11:04:16 +0100 |
parents | a440f0514c2a |
children | a7ef9b765891 |
comparison
equal
deleted
inserted
replaced
2488:590ac12b7671 | 2489:9d154c929319 |
---|---|
89 local random; | 89 local random; |
90 repeat random = uuid(); | 90 repeat random = uuid(); |
91 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)) |
92 | 92 |
93 datamanager.list_append(origin.username, origin.host, module.name, { filename = join_path(storage_path, random, filename), size = filesize, time = os.time() }); | 93 datamanager.list_append(origin.username, origin.host, module.name, { filename = join_path(storage_path, random, filename), size = filesize, time = os.time() }); |
94 pending_slots[random.."/"..filename] = origin.full_jid; | 94 local slot = random.."/"..filename; |
95 pending_slots[slot] = origin.full_jid; | |
95 local base_url = module:http_url(); | 96 local base_url = module:http_url(); |
96 local slot_url = url.parse(base_url); | 97 local slot_url = url.parse(base_url); |
97 slot_url.path = url.parse_path(slot_url.path or "/"); | 98 slot_url.path = url.parse_path(slot_url.path or "/"); |
98 t_insert(slot_url.path, random); | 99 t_insert(slot_url.path, random); |
99 t_insert(slot_url.path, filename); | 100 t_insert(slot_url.path, filename); |
101 slot_url.path = url.build_path(slot_url.path); | 102 slot_url.path = url.build_path(slot_url.path); |
102 slot_url = url.build(slot_url); | 103 slot_url = url.build(slot_url); |
103 reply:tag("get"):text(slot_url):up(); | 104 reply:tag("get"):text(slot_url):up(); |
104 reply:tag("put"):text(slot_url):up(); | 105 reply:tag("put"):text(slot_url):up(); |
105 origin.send(reply); | 106 origin.send(reply); |
106 origin.log("debug", "Given upload slot %q", random); | 107 origin.log("debug", "Given upload slot %q", slot); |
107 return true; | 108 return true; |
108 end); | 109 end); |
109 | 110 |
110 -- http service | 111 -- http service |
111 local function upload_data(event, path) | 112 local function upload_data(event, path) |