Storing data in the cloud: S3, WebDAV, Koofr™ and Seafile™

Jennifer

Object storage, a file protocol and two file-sync services from one Jennifer program, and a backup job that mirrors a folder to two of them.

November 2026, by @mplx.
Based on Jennifer 0.27.0

Powered by Jennifer's Cantrip - Markdown into slide decks, https://github.com/jennifer-language/cantrip
1 / 23

Three ways to keep files in the cloud

Object storageWebDAVFile sync
ExamplesS3, MinIO, R2, B2Nextcloud™, a NAS, ApacheKoofr, Seafile
You storean object under a keya file in a foldera file in a library
Foldersnone: / is part of the keyreal collectionsreal folders
Sharingpresigned URLsdepends on the serverpublic and upload links
Extrasmetadata, huge scaleproperties, If-Matchhistory, trash, clients

Rule of thumb: programs write to buckets, people work in sync services, and WebDAV connects the two.

2 / 23

The setup

BackendIn Jennifer 0.26.0For this talk, on 127.0.0.1
S3import "s3.j", bundledMinIO (Bitnami™ image)
WebDAVimport "webdav.j", bundledApache httpd 2.4 with mod_dav
Koofr@deckyard/koofr 0.3.0a stand-in written in Jennifer
Seafile@deckyard/seafile 0.2.0Seafile 12.0.14, MariaDB™
jvc add @deckyard/koofr
jvc add @deckyard/seafile
jvc install                  # copies both into vendor/deckyard/
3 / 23

S3: keys, metadata and a listing

def r as http.Response init s3.put($c, BUCKET, "notes/todo.txt",
    "buy milk\n");
$r = s3.putWith($c, BUCKET, "photos/2026/cat.txt", "meow\n",
    "text/plain", {"owner": "alice", "source": "phone"});
$r = s3.head($c, BUCKET, "photos/2026/cat.txt");
for (def k in s3.objectKeys(s3.listObjects($c, BUCKET).body)) {
    if (strings.startsWith($k, "photos/")) {       # no prefix param
        io.printf("  %s\n", $k);
put 200, ETag "8bc0d2e9ed325bc04c190eb7b9554293"
head 200 text/plain owner=alice
  photos/2026/cat.txt
  photos/2026/dog.txt
4 / 23

S3: errors are values, links are signed

def r as http.Response init s3.get($c, BUCKET, "notes/missing.txt");
if ($r.status != 200) {                   # a value, not an exception
    def e as s3.S3Error init s3.errorOf($r);
    io.printf("%s\n", $e.message);       # also .status, .code
}
def u as string init s3.presign($c, "GET", BUCKET, "notes/todo.txt",
    600);                                 # valid for ten minutes
$r = http.get($u, {});                  # no key, no secret
s3: HTTP 404: NoSuchKey: The specified key does not exist.
http://127.0.0.1:19000/backups/notes/todo.txt?X-Amz-Algorithm=AWS4-...
presigned GET: 200 buy milk
copy 200, delete 204
5 / 23

S3: a large file in parts

try {                       # $id from s3.createMultipartUpload
    while (not fs.eof($f)) {
        def part as bytes init fs.readBytes($f, PART);   # 5 MiB
        def n as int init len($etags) + 1;
        def tag as string init s3.uploadPart($c, BUCKET, $key, $id, $n,
            $part);
        if ($tag != md5($part)) {          # a part's ETag is its MD5
            throw Error{kind: "s3", message: "part {$n}: ETag {$tag}"};
        }
        $etags[] = $tag;
    }                              # then completeMultipartUpload
} catch (e) {
    s3.abortMultipartUpload($c, BUCKET, $key, $id);   # no orphan parts
6 / 23

What the bucket got

$ jennifer run multipart.j big.bin        # 12 MiB of random bytes
part 1: 5242880 bytes, "3444246a098524ccc36de44625223b02"
part 2: 5242880 bytes, "e3ca769140c11b8a1178225410618812"
part 3: 2097152 bytes, "8ddd0f15a40f66ae3d6681b7f361ced5"
complete: "f3c2ccff0eaf19c1b55423a8587bb578-3"
7 / 23

One module, many providers

Storeendpointregion
AWS™ S3https://s3.<region>.amazonaws.comthe bucket's region
MinIOhttp://host:9000us-east-1 or as configured
Cloudflare™ R2https://<account>.r2.cloudflarestorage.comauto
Backblaze™ B2https://s3.<region>.backblazeb2.comthe bucket's region
8 / 23

WebDAV: HTTP verbs for a file tree

def c as webdav.Client init webdav.connect(os.getEnv("DAV_URL"));
...                                     # withBasicAuth, see below
webdav.mkdirAll($c, "/Backups/2026/11");                 # MKCOL x3
webdav.put($c, "/Backups/2026/11/notes.txt", $text);     # PUT
webdav.copy($c, "/Backups/2026/11/notes.txt", "/Backups/copy.txt",
    false);                                              # COPY
webdav.move($c, "/Backups/copy.txt", "/Backups/old.txt", false);
for (def r in webdav.readDir($c, "/Backups")) {          # PROPFIND
    io.printf("%s %t %d %s\n", $r.path, $r.isDir, $r.size, $r.etag);
}
/Backups/2026 true 0 W/"4-660a094cbc076"
/Backups/old.txt false 9 W/"9-660a094cbdbce"
9 / 23

Never overwrite someone else's change

func save(c as webdav.Client, p as string, s as string, t as string) {
    def o as webdav.PutOptions;
    $o.ifMatch = $t;                      # only if nobody changed it
    webdav.putWith($c, $p, encoding.encode("utf-8", $s), $o);
}
def mine as string init webdav.stat($c, $p).etag;
save($c, $p, "buy milk and bread\n", $mine);      # another writer
try {
    save($c, $p, "buy milk and eggs\n", $mine);   # my stale copy
read     "9-660a094cbcc2e"
changed  W/"13-660a094ebac70"
refused  412 PUT /Backups/2026/11/notes.txt
10 / 23

Nextcloud and ownCloud are WebDAV servers

def const FAV as string init "\{http://owncloud.org/ns\}favorite";
webdav.proppatch($c, "/report.txt", {FAV: "1"}, []);    # PROPPATCH
def size as string init webdav.clark(webdav.DAV_NS, "getcontentlength");
for (def r in webdav.propfind($c, "/report.txt", 0, [FAV, $size])) {
    io.printf("%s favorite=%s size=%d\n", $r.path, $r.props[FAV], $r.size);
}
/report.txt favorite=1 size=17
11 / 23

Koofr: mounts, files and links

def c as koofr.Client init koofr.client(os.getEnv("KOOFR_URL"));
$c = koofr.withAppPassword($c, os.getEnv("KOOFR_EMAIL"),
    os.getEnv("KOOFR_PASSWORD"));
def m as koofr.Mount init koofr.primaryMount($c);
koofr.mkdirAll($c, $m.id, "/Backups/2026/11");
def opts as koofr.PutOptions;                     # zero value: refuse
def f as koofr.File init koofr.put($c, $m.id,
    "/Backups/2026/11/notes.txt", $data, $opts);
def l as koofr.Link init koofr.createLink($c, $m.id, $f.path);
mount Koofr (hosted), id m-1
put /Backups/2026/11/notes.txt, 9 bytes
link https://k00.fr/l-1
409 AlreadyExists
12 / 23

Seafile: libraries, files and links

def token as string init seafile.login($c, os.getEnv("SEAFILE_USER"),
    os.getEnv("SEAFILE_PASSWORD"), "");          # "" = no 2FA code
$c = seafile.withRetries(seafile.withToken($c, $token), 3);
def l as seafile.Library init seafile.createLibrary($c, "Backups", "");
seafile.mkdir($c, $l.id, "/2026/11", true);      # with parents
def e as seafile.Entry init seafile.put($c, $l.id,
    "/2026/11/notes.txt", $data, true);          # replace if there
def s as seafile.ShareLink init seafile.createShareLink($c, $l.id,
    $e.path, $o);
def u as seafile.UploadLink init seafile.createUploadLink($c, $l.id,
    "/2026", "", 0);                             # open, no expiry
share  http://127.0.0.1:18082/f/32f60e01fa014b979340/
upload http://127.0.0.1:18082/u/d/a4e4838287d74f0988be/
13 / 23

Seafile: encrypted libraries

def v as seafile.Library init seafile.createLibrary($c, "Vault", $secret);
unlock($c, $v.id, "not-the-password");
unlock($c, $v.id, $secret);
seafile.put($c, $v.id, "/secret.txt", $pin, true);
Vault encrypted=true
decrypt: 400 seafile: POST /api2/repos/5711fbd7-4942-4ae5-922f-
  f2198d3282ea/: HTTP 400: Incorrect password
decrypt: ok
get: pin 0000
14 / 23

Errors: one struct per backend

S3WebDAVKoofrSeafile
Refusedreturns the responsethrowsthrowsthrows
Kinds3 (errorOf)webdavkoofrseafile
StructS3ErrorWebdavErrorKoofrErrorSeafileError
Fieldsstatus code requestIdstatus method path memberstatus codestatus

Shared by all: net (a net.NetError), limit, timeout, closed. Match the kind, assign to the struct, then read its fields.

15 / 23

The statuses you will meet

stale: 412 PUT /Backups/2026/11/notes.txt
new: 412 PUT /Backups/2026/11/notes.txt
missing: 404 GET /nope.txt
parent: 409 PUT /no/dir/a.txt
mkdir: 405 MKCOL /Backups
auth: 401 PROPFIND /
StatusMeansDo
404, 409missing file, or missing parent foldercreate the parent, or skip
412If-Match or If-None-Match failedread again, merge, retry
429, 5xxtoo many requests, server troublewait and retry
401, 403credentials, permissionsstop and alert a person
16 / 23

Retries: who does what

for (def attempt in 1..5) {       # $opts.overwrite: idempotent
    try {
        koofr.put($c, $m.id, "/notes.txt", $data, $opts);
        break;
    } catch (e) {
        ...                                 # KoofrError, 429 or 5xx?
        time.sleep(time.fromSeconds($attempt));
HTTP 429, retry in 1 s
HTTP 429, retry in 2 s
stored after 3 attempt(s)
17 / 23

Large files and limits

Download capLarge uploads
S3nonemultipart, 5 MiB parts
WebDAVget(c, p, maxBytes): 0 means 64 MiBone PUT from bytes
Koofrget(..., maxBytes): 0 means 64 MiBone POST from bytes
Seafileget(..., maxBytes): 0 means 64 MiBputResumable, 8 MiB chunks
[limit] webdav: GET /big.bin: http: response body exceeds 1048576 bytes
/big.bin: 12582912 bytes in Backups
18 / 23

Checksums: trust, but verify

The server gives youIs it the file's hash?
S3ETagMD5 for one PUT; not for multipart
WebDAVETagno: Apache uses size and time
KoofrFile.hashMD5 of the content
SeafileEntry.idan object id, not a hash of the bytes

So: compute SHA-256 yourself, before the upload, and store it where the file goes: S3 metadata, or a SHA256SUMS file beside the files.

19 / 23

Credentials

[koofr] koofr: credentials go over http:// only to a loopback host; use
  https:// or withPlainHttp, got "http://files.example.com"
token for Backups, permission r
[seafile] seafile: GET /api/v2.1/via-repo-token/upload-link/?path=%2F:
  HTTP 403: You do not have permission to access this folder.
20 / 23

A backup job: mirror one folder to two backends

func mirror(t as Target, root as string,
    local as map of string to string) {
    def remote as map of string to string init readRemote($t);
    for (def rel in lists.sort(maps.keys($local))) {
        def want as string init $local[$rel];
        if (not maps.has($remote, $rel) or $remote[$rel] != $want) {
            send($t, $rel, fs.readBytes($root + "/" + $rel));
        }
    }
    ...                    # remove what is in $remote, not in $local
    def text as string init render($local);
    send($t, MANIFEST, encoding.encode("utf-8", $text)); # last
21 / 23

Four runs, one outage

$ jennifer run backup.j docs
s3: 3 sent, 0 removed, 0 unchanged
webdav: 3 sent, 0 removed, 0 unchanged
$ jennifer run backup.j docs          # one file changed, one deleted
s3: 1 sent, 1 removed, 1 unchanged
webdav: 1 sent, 1 removed, 1 unchanged
$ jennifer run backup.j docs          # the WebDAV server is stopped
s3: 1 sent, 0 removed, 1 unchanged
webdav: [net] net.connect: 127.0.0.1:18081: dial tcp 127.0.0.1:18081:
  connect: connection refused
exit 1
22 / 23

Takeaways and read more

Based on Jennifer 0.27.0, November 2026.

23 / 23