Documentation
¶
Overview ¶
Package dav is the explorer's WebDAV client: what browsing, downloading and uploading a share's files need of RFC 4918, and nothing else -- no locks, no properties beyond the four a listing shows.
It talks through any HTTP client (Doer): in a browser, the portal's (go-fileshare/portal/client), which adds the portal's header and keeps the token fresh; in a test, a plain one.
Index ¶
- func Exists(err error) bool
- type Client
- func (c *Client) Copy(ctx context.Context, from, to string) error
- func (c *Client) Delete(ctx context.Context, p string) error
- func (c *Client) DownloadURL(p string) string
- func (c *Client) List(ctx context.Context, dir string) ([]Entry, error)
- func (c *Client) Mkdir(ctx context.Context, p string) error
- func (c *Client) Move(ctx context.Context, from, to string) error
- func (c *Client) Upload(ctx context.Context, p string, src Source, overwrite bool, ...) (err error)
- type Doer
- type Entry
- type Error
- type Source
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// Piece is the size of one upload piece. Default 8 MiB: the portal
// takes 16 MiB at most per PUT, and a smaller piece is a finer progress
// bar and a smaller retry.
Piece int64
// contains filtered or unexported fields
}
Client is the WebDAV of one server, rooted at base -- the portal's /dav/<server>, or a server's own URL.
func (*Client) DownloadURL ¶
DownloadURL is where a browser fetches p: a navigation, which the portal answers as an attachment.
func (*Client) List ¶
List is what the collection dir holds (PROPFIND, Depth 1), collections first, then by name; dir itself is not in it.
func (*Client) Move ¶
Move renames from to to; Copy copies it there, on the server. Neither replaces what is there already: Overwrite is F (RFC 4918 §10.6 makes T the default, which would silently destroy a file a rename landed on), and an existing destination is an error Exists recognises. A 207 is a move or copy that failed in part, and is an error too.
func (*Client) Upload ¶
func (c *Client) Upload(ctx context.Context, p string, src Source, overwrite bool, progress func(sent int64)) (err error)
Upload writes src at p, in pieces: an empty PUT of p.part, each piece appended where the last ended (go-filesystems/webdav v0.6.0), then a MOVE to p -- so nobody sees half a file under its name, and no request holds the whole file. progress, when not nil, is told the bytes sent so far. A failure leaves p as it was, and tries to remove the part file.
type Entry ¶
type Entry struct {
Name string
Path string // from the root of the server's WebDAV, with a leading /; a collection's ends in /
Dir bool
Size int64
Modified time.Time
}
An Entry is one resource of a listing.