Documentation
¶
Overview ¶
Package gowebdav is a WebDAV client library.
Index ¶
Constants ¶
View Source
const ( MethodMove = "MOVE" MethodCopy = "COPY" MethodMkcol = "MKCOL" MethodPropfind = "PROPFIND" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
// Ping tests the connection to the webdav server.
Ping() error
// ReadDir reads the contents of a remote directory
ReadDir(path string) ([]os.FileInfo, error)
// Copy copies a file from oldpath to newpath.
// If newpath already exists and is not a directory, Copy overwrites it.
Copy(oldpath, newpath string) error
// CopyWithoutOverwriting copies a file from oldpath to newpath.
CopyWithoutOverwriting(oldpath, newpath string) error
// ReadFile reads the contents of a remote file.
ReadFile(path string) ([]byte, error)
// ReadStream reads the stream for a given path. The caller must
// close the returned io.ReadCloser.
ReadStream(path string) (io.ReadCloser, error)
// WriteFile writes data to a given path on the webdav server.
WriteFile(path string, data []byte, contentType string) error
// WriteStream writes from a stream to a resource on the webdav server.
WriteStream(path string, stream io.Reader, contentType string) error
// Mkdir makes a directory (also known as a collection in Webdav)
Mkdir(path string, perm os.FileMode) error
// MkdirAll creates a directory path and all parents that do not exist yet.
MkdirAll(path string, perm os.FileMode) error
// Remove removes a remote file
Remove(path string) error
// RemoveAll removes remote files
RemoveAll(path string) error
// Rename renames (moves) oldpath to newpath.
// If newpath already exists and is not a directory, Rename replaces it.
Rename(oldname, newname string) error
// RenameWithoutOverwriting renames (moves) oldpath to newpath.
// If newpath already exists, a *os.PathError error is returned
// containing the message "file already exists".
RenameWithoutOverwriting(oldpath, newpath string) error
// Stat returns a FileInfo describing the named file, or an error, if any happens.
Stat(path string) (os.FileInfo, error)
// The name of this FileSystem.
Name() string
}
Client is compatible with Afero.Fs. https://pkg.go.dev/github.com/spf13/afero#Fs
type ClientOpt ¶
type ClientOpt func(Client)
func SetAuthentication ¶
func SetAuthentication(authenticator auth.Authenticator) ClientOpt
SetAuthentication sets the authentication credentials and method. Leave the authenticator method blank to allow HTTP challenges to select an appropriate method. Otherwise it should be "basic".
func SetHttpClient ¶
func SetHttpClient(httpClient HttpClient) ClientOpt
SetHttpClient changes the http.Client. This allows control over the http.Transport, timeouts etc.
Click to show internal directories.
Click to hide internal directories.