Software /
code /
prosody
Changeset
11310:d1a0f2e918c0
mod_http_file_share: Add support for external file upload service
PUT /upload/:slot/:filename
Authorization: Bearer JWT{ uploader, filename, filesize, filetype, exp }
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 26 Jan 2021 14:27:51 +0100 |
parents | 11309:b59aed75dc5e |
children | 11311:9edda2026e57 |
files | doc/doap.xml plugins/mod_http_file_share.lua |
diffstat | 2 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/doap.xml Tue Jan 26 03:19:17 2021 +0100 +++ b/doc/doap.xml Tue Jan 26 14:27:51 2021 +0100 @@ -619,7 +619,7 @@ <xmpp:SupportedXep> <xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0363.html"/> <xmpp:version>1.0.0</xmpp:version> - <xmpp:status>complete</xmpp:status> + <xmpp:status>complete </xmpp:status> <xmpp:since>0.12.0</xmpp:since> <xmpp:note>mod_http_file_share</xmpp:note> </xmpp:SupportedXep>
--- a/plugins/mod_http_file_share.lua Tue Jan 26 03:19:17 2021 +0100 +++ b/plugins/mod_http_file_share.lua Tue Jan 26 14:27:51 2021 +0100 @@ -17,7 +17,6 @@ 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 @@ -- 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 @@ 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 @@ 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 @@ ["GET /*"] = handle_download; } }); +end