TUS in prolog
Announcing the release of v0.0.1 of TUS in prolog implementation of the TUS protocol for resumable file uploads via HTTP (see: Tus)
The implementation can be found on GitHub here structured as a SWI-Prolog package.
Examples
Server
To use the TUS server with the HTTP library in swipl you can simply
add a tus_dispatch
call to your http_handler from a chosen endpoint
as follows:
:- http_handler(root(files), tus_dispatch,
[ methods([options,head,post,patch]),
prefix
]).
In order to determine the location of a given resource when passed the
resource URL in other contexts you can use the utility predicate
tus_uri_resource(URI, Resource)
together with
tus_resource_path(Resource, Resource_Path)
. In this way once a
client has uploaded a resource it can be referred to in client-server
communications, and be moved, modified or manipulated by server code.
Client
The client invocation requires only the endpoint of interest and a
file and can be invoked thus:
tus_upload(Example, URL, Resource)
The Resource
variable gives back a resource handle that the server can use to
refer to the resource in subsequent communication.
TODO
The remaining extensions would be desirable:
- Checksum
- Concatenation
- Termination
Copyright
Licensed under the Apache License, Version 2.0 (the “License”); you
may not use this file except in compliance with the License. You may
obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0