GoWebDAV
A golang WebDAV client library.
Main features
gowebdav
library allows to perform following actions on the remote WebDAV server:
Usage
First of all you should create Client
instance using NewClient()
function:
After you can use this Client
to perform actions, described below.
NOTICE: we will not check errors in examples, to focus you on the gowebdav
library's code, but you should do it in your code!
Create path on a WebDAV server
In case you want to create several folders you can use c.MkdirAll()
:
Get files list
Download file to byte array
Download file via reader
Also you can use c.ReadStream()
method:
Upload file from byte array
Upload file via writer
Get information about specified file/folder
Move file to another location
Copy file to another location
Delete file
Links
More details about WebDAV server you can read from following resources:
RFC 4918 - HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)
RFC 5689 - Extended MKCOL for Web Distributed Authoring and Versioning (WebDAV)
WebDav: Next Generation Collaborative Web Authoring By Lisa Dusseaul
NOTICE: RFC 2518 is obsoleted by RFC 4918 in June 2007
Contributing
All contributing are welcome. If you have any suggestions or find some bug - please create an Issue to let us make this project better. We appreciate your help!
License
This library is distributed under the BSD 3-Clause license found in the LICENSE file.
API
import "github.com/studio-b12/gowebdav"
Overview
Package gowebdav is a WebDAV client library with a command line tool included.
Index
func (c *Client) Copy(oldpath, newpath string, overwrite bool) error
func (c *Client) ReadDir(path string) ([]os.FileInfo, error)
func (c *Client) ReadStream(path string) (io.ReadCloser, error)
func (c *Client) ReadStreamRange(path string, offset, length int64) (io.ReadCloser, error)
func (c *Client) Rename(oldpath, newpath string, overwrite bool) error
func (c *Client) SetInterceptor(interceptor func(method string, rq *http.Request))
func (c *Client) Write(path string, data []byte, _ os.FileMode) error
func (c *Client) WriteStream(path string, stream io.Reader, _ os.FileMode) error
Examples
Package files
basicAuth.go client.go digestAuth.go doc.go file.go netrc.go requests.go utils.go
func FixSlash
FixSlash appends a trailing / to our string
func FixSlashes
FixSlashes appends and prepends a / if they are missing
func Join
Join joins two paths
func PathEscape
PathEscape escapes all segments of a given path
func ReadConfig
ReadConfig reads login and password configuration from ~/.netrc machine foo.com login username password 123456
func String
String pulls a string out of our io.Reader
type Authenticator
Authenticator stub
type BasicAuth
BasicAuth structure holds our credentials
func (*BasicAuth) Authorize
Authorize the current request
func (*BasicAuth) Pass
Pass holds the BasicAuth password
func (*BasicAuth) Type
Type identifies the BasicAuthenticator
func (*BasicAuth) User
User holds the BasicAuth username
type Client
Client defines our structure
func NewClient
NewClient creates a new instance of client
func (*Client) Connect
Connect connects to our dav server
func (*Client) Copy
Copy copies a file from A to B
func (*Client) Mkdir
Mkdir makes a directory
func (*Client) MkdirAll
MkdirAll like mkdir -p, but for webdav
func (*Client) Read
Read reads the contents of a remote file
func (*Client) ReadDir
ReadDir reads the contents of a remote directory
func (*Client) ReadStream
ReadStream reads the stream for a given path
func (*Client) ReadStreamRange
ReadStreamRange reads the stream representing a subset of bytes for a given path, utilizing HTTP Range Requests if the server supports it. The range is expressed as offset from the start of the file and length, for example offset=10, length=10 will return bytes 10 through 19.
If the server does not support partial content requests and returns full content instead, this function will emulate the behavior by skipping offset
bytes and limiting the result to length
.
func (*Client) Remove
Remove removes a remote file
func (*Client) RemoveAll
RemoveAll removes remote files
func (*Client) Rename
Rename moves a file from A to B
func (*Client) SetHeader
SetHeader lets us set arbitrary headers for a given client
func (*Client) SetInterceptor
SetInterceptor lets us set an arbitrary interceptor for a given client
func (*Client) SetTimeout
SetTimeout exposes the ability to set a time limit for requests
func (*Client) SetTransport
SetTransport exposes the ability to define custom transports
func (*Client) Stat
Stat returns the file stats for a specified path
func (*Client) Write
Write writes data to a given path
func (*Client) WriteStream
WriteStream writes a stream
type DigestAuth
DigestAuth structure holds our credentials
func (*DigestAuth) Authorize
Authorize the current request
func (*DigestAuth) Pass
Pass holds the DigestAuth password
func (*DigestAuth) Type
Type identifies the DigestAuthenticator
func (*DigestAuth) User
User holds the DigestAuth username
type File
File is our structure for a given file
func (File) ContentType
ContentType returns the content type of a file
func (File) ETag
ETag returns the ETag of a file
func (File) IsDir
IsDir let us see if a given file is a directory or not
func (File) ModTime
ModTime returns the modified time of a file
func (File) Mode
Mode will return the mode of a given file
func (File) Name
Name returns the name of a file
func (File) Path
Path returns the full path of a file
func (File) Size
Size returns the size of a file
func (File) String
String lets us see file information
func (File) Sys
Sys ????
type NoAuth
NoAuth structure holds our credentials
func (*NoAuth) Authorize
Authorize the current request
func (*NoAuth) Pass
Pass returns the current password
func (*NoAuth) Type
Type identifies the authenticator
func (*NoAuth) User
User returns the current user
Generated by godoc2md