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 ¶
- type Driver
- func (d *Driver) Capabilities() storage.Capabilities
- func (d *Driver) Copy(ctx context.Context, src, dst string) error
- func (d *Driver) Delete(ctx context.Context, p string) error
- func (d *Driver) Init(_ context.Context, cfg map[string]any) error
- func (d *Driver) List(ctx context.Context, p string) ([]storage.Object, error)
- func (d *Driver) Mkdir(ctx context.Context, p string) error
- func (d *Driver) Move(ctx context.Context, src, dst string) error
- func (d *Driver) Name() string
- func (d *Driver) Read(ctx context.Context, p string) (io.ReadCloser, error)
- func (d *Driver) ReadRange(ctx context.Context, p string, off, length int64) (io.ReadCloser, error)
- func (d *Driver) Stat(ctx context.Context, p string) (storage.Object, error)
- func (d *Driver) Write(ctx context.Context, p string, r io.Reader, size int64) error
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) Init ¶
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) ReadRange ¶
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.