Diff

mod_http_upload/mod_http_upload.lua @ 2066:cb74e4ab13f0

mod_http_upload: Advertise maximum file size in disco#info (Per XEP-0363 v0.2)
author Kim Alvefur <zash@zash.se>
date Tue, 08 Mar 2016 19:36:27 +0100
parent 2065:624e3fed6f92
child 2191:e47046abf568
line wrap: on
line diff
--- a/mod_http_upload/mod_http_upload.lua	Mon Mar 07 13:47:13 2016 +0100
+++ b/mod_http_upload/mod_http_upload.lua	Tue Mar 08 19:36:27 2016 +0100
@@ -12,6 +12,7 @@
 local lfs = require"lfs";
 local uuid = require"util.uuid".generate;
 local urlencode = require"util.http".urlencode;
+local dataform = require "util.dataforms".new;
 local t_concat = table.concat;
 local t_insert = table.insert;
 local s_upper = string.upper;
@@ -32,6 +33,11 @@
 
 module:add_feature(xmlns_http_upload);
 
+module:add_extension(dataform {
+	{ name = "FORM_TYPE", type = "hidden", value = xmlns_http_upload },
+	{ name = "max-file-size", type = "text-single" },
+}:form({ ["max-file-size"] = tostring(file_size_limit) }, "result"));
+
 -- state
 local pending_slots = module:shared("upload_slots");