2015-08-20 00:33:34 +02:00
|
|
|
|
|
|
|
mod_http_upload - HTTP File Upload
|
|
|
|
|
|
|
|
Author: Holger Weiss <holger@zedat.fu-berlin.de>
|
|
|
|
Requirements: ejabberd 13.06 or newer
|
|
|
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
|
|
|
|
|
|
|
This module allows for requesting permissions to upload a file via HTTP.
|
|
|
|
If the request is accepted, the client receives a URL to use for uploading
|
|
|
|
the file and another URL from which that file can later be downloaded.
|
|
|
|
|
|
|
|
PLEASE NOTE: This module implements an experimental protocol which has NOT
|
|
|
|
been approved by the XMPP Standards Foundation and may change at any time:
|
|
|
|
|
2015-08-23 18:06:12 +02:00
|
|
|
http://xmpp.org/extensions/inbox/http-upload.html
|
2015-08-20 00:33:34 +02:00
|
|
|
|
|
|
|
There are already suggestions for improvements, e.g. from ProcessOne:
|
|
|
|
|
2015-08-23 18:06:12 +02:00
|
|
|
https://github.com/processone/ejabberd-saas-docs/blob/master/xmpp-specs/http-filetransfer/http-filetransfer.md
|
2015-08-20 00:33:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
CONFIGURATION
|
|
|
|
-------------
|
|
|
|
|
|
|
|
In order to use this module, add configuration snippets such as the
|
|
|
|
following to your ejabberd.yml file:
|
|
|
|
|
|
|
|
listen:
|
|
|
|
# [...]
|
|
|
|
-
|
|
|
|
module: ejabberd_http
|
|
|
|
port: 5443
|
|
|
|
tls: true
|
|
|
|
certfile: "/etc/ejabberd/example.com.pem"
|
|
|
|
request_handlers:
|
|
|
|
"": mod_http_upload
|
|
|
|
|
|
|
|
modules:
|
|
|
|
# [...]
|
|
|
|
mod_http_upload:
|
|
|
|
docroot: "/home/xmpp/upload"
|
2015-08-23 17:58:26 +02:00
|
|
|
put_url: "https://@HOST@:5443"
|
2015-08-20 00:33:34 +02:00
|
|
|
|
|
|
|
The configurable mod_http_upload options are:
|
|
|
|
|
|
|
|
- host (default: "upload.@HOST@")
|
|
|
|
|
|
|
|
This option defines the JID for the HTTP upload service. The keyword
|
|
|
|
@HOST@ is replaced with the virtual host name.
|
|
|
|
|
|
|
|
- name (default: "HTTP File Upload")
|
|
|
|
|
|
|
|
This option defines the Service Discovery name for the HTTP upload
|
|
|
|
service.
|
|
|
|
|
|
|
|
- access (default: 'local')
|
|
|
|
|
|
|
|
This option defines the access rule to limit who is permitted to use the
|
|
|
|
HTTP upload service. The default value is 'local'. If no access rule of
|
|
|
|
that name exists, no user will be allowed to use the service.
|
|
|
|
|
|
|
|
- max_size (default: 104857600)
|
|
|
|
|
|
|
|
This option limits the acceptable file size. Either a number of bytes
|
|
|
|
(larger than zero) or 'infinity' must be specified.
|
|
|
|
|
2015-08-22 00:45:45 +02:00
|
|
|
- secret_length (default: 40)
|
|
|
|
|
|
|
|
This option defines the length of the random string included in the GET
|
|
|
|
and PUT URLs generated by mod_http_upload. The minimum length is 8
|
|
|
|
characters, but it is recommended to choose a larger value.
|
|
|
|
|
2015-08-21 23:22:48 +02:00
|
|
|
- jid_in_url (default: 'sha1')
|
|
|
|
|
|
|
|
When this option is set to 'node', the node identifier of the user's JID
|
|
|
|
(i.e., the user name) is included in the GET and PUT URLs generated by
|
|
|
|
mod_http_upload. Otherwise, a SHA-1 hash of the user's bare JID is
|
|
|
|
included instead.
|
|
|
|
|
2015-08-23 17:58:26 +02:00
|
|
|
- docroot (default: "@HOME@/upload")
|
2015-08-20 00:33:34 +02:00
|
|
|
|
|
|
|
Uploaded files are stored below the directory specified (as an absolute
|
|
|
|
path) with this option. It is mandatory to specify either this option or
|
2015-08-23 17:47:19 +02:00
|
|
|
the 'service_url' option. The keyword @HOME@ is replaced with the home
|
|
|
|
directory of the user running ejabberd.
|
2015-08-20 00:33:34 +02:00
|
|
|
|
2015-08-23 17:58:26 +02:00
|
|
|
- put_url (default: "http://@HOST@:5444")
|
2015-08-20 00:33:34 +02:00
|
|
|
|
|
|
|
This option specifies the initial part of the PUT URLs used for file
|
2015-08-23 17:47:19 +02:00
|
|
|
uploads. The keyword @HOST@ is replaced with the virtual host name.
|
2015-08-20 00:33:34 +02:00
|
|
|
|
2015-08-24 21:32:37 +02:00
|
|
|
NOTE: Different virtual hosts cannot use the same PUT URL domain.
|
|
|
|
|
2015-08-20 00:33:34 +02:00
|
|
|
- get_url (default: $put_url)
|
|
|
|
|
|
|
|
This option specifies the initial part of the GET URLs used for
|
|
|
|
downloading the files. By default, it is set to the same value as the
|
|
|
|
'put_url', but you can set it to a different value in order to have the
|
2015-08-23 17:47:19 +02:00
|
|
|
files served by a proper HTTP server such as Nginx or Apache. The keyword
|
|
|
|
@HOST@ is replaced with the virtual host name.
|
2015-08-20 00:33:34 +02:00
|
|
|
|
|
|
|
- service_url (default: 'undefined')
|
|
|
|
|
|
|
|
If a 'service_url' is specified, HTTP upload slot requests are forwarded
|
|
|
|
to this external service instead of being handled by mod_http_upload
|
2015-08-23 19:37:09 +02:00
|
|
|
itself. An HTTP GET query such as the following is issued whenever an
|
|
|
|
HTTP upload slot request is accepted as per the 'access' rule:
|
2015-08-20 00:33:34 +02:00
|
|
|
|
2015-08-23 18:06:12 +02:00
|
|
|
http://localhost:5444/?jid=juliet%40example.com&size=10240&name=example.jpg
|
2015-08-20 00:33:34 +02:00
|
|
|
|
|
|
|
In order to accept the request, the service must return an HTTP status
|
|
|
|
code of 200 or 201 and two lines of text/plain output. The first line is
|
|
|
|
forwarded to the XMPP client as the HTTP upload PUT URL, the second line
|
|
|
|
as the GET URL.
|
|
|
|
|
|
|
|
In order to reject the request, the service should return one of the
|
|
|
|
following HTTP status codes:
|
|
|
|
|
|
|
|
- 402
|
|
|
|
In this case, a 'resource-constraint' error stanza is sent to the
|
|
|
|
client. Use this to indicate a temporary error after the client
|
|
|
|
exceeded a quota, for example.
|
|
|
|
|
|
|
|
- 403
|
|
|
|
In this case, a 'not-allowed' error stanza is sent to the client. Use
|
|
|
|
this to indicate a permanent error to a client that is not permitted to
|
|
|
|
upload files, for example.
|
|
|
|
|
|
|
|
- 413
|
|
|
|
In this case, a 'not-acceptable' error stanza is sent to the client.
|
|
|
|
Use this if the file size was too large, for example.
|
|
|
|
|
|
|
|
In any other case, a 'service-unavailable' error stanza is sent to the
|
|
|
|
client.
|
2015-08-23 17:22:32 +02:00
|
|
|
|
|
|
|
- rm_on_unregister (default: 'true')
|
|
|
|
|
|
|
|
This option specifies whether files uploaded by a user should be removed
|
|
|
|
when that user is unregistered. It must be set to 'false' if this is not
|
|
|
|
desired.
|