Did you know ... Search Documentation:
Pack tus -- prolog/tus.pl
PublicShow source

Both client and server implementation of the TUS protocol.

The TUS protocol allows resumable file uploads via HTTP in swipl https://tus.io/

Server implementation

Requests are structured according to the prolog http library format.

Implemented features of the TUS protocol:

OPTIONS (Discovery) POST (Create)* HEAD (Find resumption point) PATCH (Send chunk)

Suggested

 set_tus_options(+Options) is det
Sets the global options for the tus server and client.
Arguments:
Options- Includes the following options:
  • tus_storage_path(Path): Location of server storage folder.
  • tus_max_size(Size): Maximum chunk size accepted by the server.
  • tus_client_chunk_size(Size)): Size of chunks to be sent to the server.
  • tus_expiry(Expires): Expires after Expires seconds.
 tus_resource_path(+Resource, -Path, +Options) is det
(Server) Return a fully qualified path for the given resource (assuming fully uploaded).
Arguments:
Resource- The resource which is referenced
Path- The file path location of the associated resource
Options- A list which includes:
  • domain(Domain): The domain in which to store the file (to avoid collisions)
 tus_uri_resource(+Uri, -Resource) is det
Return a resource descriptor from the given URI endpoint
 tus_dispatch(+Options, +Request) is semidet
See tus_dispatch/2
 tus_dispatch(+Options, +Request) is semidet
Dispatches various TUS requests to the appropriate handlers.

Should be callable from http_handler/3 with something along the lines of:

` http_handler(root(files), tus_dispatch, [ methods([options,head,post,patch]), prefix ]) `
Arguments:
Options- A list with the following flags:
  • domain(Domain): An organisation/domain/user in which to isolate the file
    uploads. This can be used together with authentication. (see tests or README.md)
Request- is the standard Request object from the http_server
 tus_dispatch(+Mode, +Request) is semidet
Version of tus_dispatch/1 which includes explicit mode. The tus_dispatch/0 version is to be preferred for proper handling of 'X-HTTP-Method_Override'.
Arguments:
Mode- One of: options, head, post, patch
Request- is the standard Request object from the http_server
 tus_upload(+File, +Endpoint, -Resource_URL, +Options) is semidet
Upload File to Endpoint returning Resource_URL
Arguments:
File- A fully qualified file path
Endpoint- The URL of a TUS server
Resource_URL- The URL which refers to the uploaded resource.
Options- A list of options sent to http_get/3
 tus_resume(+Endpoint, +Resource_URL, +Options) is semidet
Resume File upload to Endpoint and Resource
Arguments:
Endpoint- The URL of a TUS server
Resource_URL- The URL which refers to the uploaded resource.
Length- Length of the file
Options- A list of options sent to http_get/3

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 tus_dispatch(Arg1)
 tus_dispatch(Arg1, Arg2, Arg3)
 tus_options(Arg1, Arg2, Arg3)
 tus_upload(Arg1, Arg2, Arg3)
 tus_resume(Arg1, Arg2, Arg3, Arg4)
 tus_delete(Arg1, Arg2, Arg3)