webdav

package
v0.46.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package webdav is a Storage Driver fronting a WebDAV server.

Tested against Nextcloud, ownCloud, Apache mod_dav, nginx-dav, and SabreDAV. Authenticates via Basic auth — Bearer is V2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

Driver is the WebDAV storage driver.

func (*Driver) Capabilities

func (d *Driver) Capabilities() storage.Capabilities

Capabilities — WebDAV supports everything except Presign and Watch.

func (*Driver) Copy

func (d *Driver) Copy(ctx context.Context, src, dst string) error

Copy implements storage.Copier.

func (*Driver) Delete

func (d *Driver) Delete(ctx context.Context, p string) error

Delete implements storage.Deleter.

func (*Driver) Init

func (d *Driver) Init(_ context.Context, cfg map[string]any) error

Init configures the driver. Required: url, user, root; password optional (some servers authenticate the URL itself).

The config keys are declared in descriptor.go — keep the two in step, there is a test that fails when they drift. Legacy spellings are read through the descriptor's aliases ("username" for user, "base_path" / "remote_path" for root).

root scopes the mount below the base URL. A row saved before the driver read it has no root, which joins to nothing: the mount stays exactly where it was.

func (*Driver) List

func (d *Driver) List(ctx context.Context, p string) ([]storage.Object, error)

List implements storage.Driver.

func (*Driver) Mkdir

func (d *Driver) Mkdir(ctx context.Context, p string) error

Mkdir implements storage.Mkdirer (MKCOL).

func (*Driver) Move

func (d *Driver) Move(ctx context.Context, src, dst string) error

Move implements storage.Mover.

func (*Driver) Name

func (d *Driver) Name() string

Name implements storage.Driver.

func (*Driver) Read

func (d *Driver) Read(ctx context.Context, p string) (io.ReadCloser, error)

Read implements storage.Driver.

func (*Driver) ReadRange

func (d *Driver) ReadRange(ctx context.Context, p string, off, length int64) (io.ReadCloser, error)

ReadRange implements storage.RangeReader with a `Range:` request header on GET.

⚠ A WebDAV server is free to ignore Range and answer 200 with the whole body. Returning that body as if it started at off would hand the caller the wrong bytes — silent corruption — so a 200 is an error whenever off > 0. At off == 0 the body is correct by construction (it starts where we asked), so the response is accepted and simply capped at length.

func (*Driver) Stat

func (d *Driver) Stat(ctx context.Context, p string) (storage.Object, error)

Stat implements storage.Driver — emulated via PROPFIND Depth:0.

func (*Driver) Write

func (d *Driver) Write(ctx context.Context, p string, r io.Reader, size int64) error

Write implements storage.Writer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL