diff options
author | Kim Alvefur <zash@zash.se> | 2021-01-26 14:27:51 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-01-26 14:27:51 +0100 |
commit | c26e8b48981a515b9b0b081f37a8412f9558c894 (patch) | |
tree | 212ba776c195738e44c741373da781ece8c87745 /plugins/mod_http_file_share.lua | |
parent | 4be9b33741b71925adddf7ee184b3babf2170347 (diff) | |
download | prosody-c26e8b48981a515b9b0b081f37a8412f9558c894.tar.gz prosody-c26e8b48981a515b9b0b081f37a8412f9558c894.zip |
mod_http_file_share: Add support for external file upload service
PUT /upload/:slot/:filename
Authorization: Bearer JWT{ uploader, filename, filesize, filetype, exp }
Diffstat (limited to 'plugins/mod_http_file_share.lua')
-rw-r--r-- | plugins/mod_http_file_share.lua | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/plugins/mod_http_file_share.lua b/plugins/mod_http_file_share.lua index 0cb610d9..c6091bd0 100644 --- a/plugins/mod_http_file_share.lua +++ b/plugins/mod_http_file_share.lua @@ -17,7 +17,6 @@ local errors = require "util.error"; local namespace = "urn:xmpp:http:upload:0"; -module:depends("http"); module:depends("disco"); module:add_identity("store", "file", module:get_option_string("name", "HTTP File Upload")); @@ -27,6 +26,11 @@ local uploads = module:open_store("uploads", "archive"); -- id, <request>, time, owner local secret = module:get_option_string(module.name.."_secret", require"util.id".long()); +local external_base_url = module:get_option_string(module.name .. "_base_url"); + +if not external_base_url then + module:depends("http"); +end function may_upload(uploader, filename, filesize, filetype) -- > boolean, error -- TODO authz @@ -45,7 +49,7 @@ function get_authz(uploader, filename, filesize, filetype, slot) end function get_url(slot, filename) - local base_url = module:http_url(); + local base_url = external_base_url or module:http_url(); local slot_url = url.parse(base_url); slot_url.path = url.parse_path(slot_url.path or "/"); t_insert(slot_url.path, slot); @@ -182,6 +186,7 @@ end module:hook("iq-get/host/urn:xmpp:http:upload:0:request", handle_slot_request); +if not external_base_url then module:provides("http", { streaming_uploads = true; route = { @@ -189,3 +194,4 @@ module:provides("http", { ["GET /*"] = handle_download; } }); +end |