webdav

package
v1.54.4 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package webdav implements a WebDAV server backed by rclone VFS

Index

Constants

This section is empty.

Variables

View Source
var Command = &cobra.Command{
	Use:   "webdav remote:path",
	Short: `Serve remote:path over webdav.`,
	Long: `
rclone serve webdav implements a basic webdav server to serve the
remote over HTTP via the webdav protocol. This can be viewed with a
webdav client, through a web browser, or you can make a remote of
type webdav to read and write it.

### Webdav options

#### --etag-hash 

This controls the ETag header.  Without this flag the ETag will be
based on the ModTime and Size of the object.

If this flag is set to "auto" then rclone will choose the first
supported hash on the backend or you can use a named hash such as
"MD5" or "SHA-1".

Use "rclone hashsum" to see the full list.

` + httplib.Help + vfs.Help + proxy.Help,
	RunE: func(command *cobra.Command, args []string) error {
		var f fs.Fs
		if proxyflags.Opt.AuthProxy == "" {
			cmd.CheckArgs(1, 1, command, args)
			f = cmd.NewFsSrc(args)
		} else {
			cmd.CheckArgs(0, 0, command, args)
		}
		hashType = hash.None
		if hashName == "auto" {
			hashType = f.Hashes().GetOne()
		} else if hashName != "" {
			err := hashType.Set(hashName)
			if err != nil {
				return err
			}
		}
		if hashType != hash.None {
			fs.Debugf(f, "Using hash %v for ETag", hashType)
		}
		cmd.Run(false, false, command, func() error {
			s := newWebDAV(f, &httpflags.Opt)
			err := s.serve()
			if err != nil {
				return err
			}
			s.Wait()
			return nil
		})
		return nil
	},
}

Command definition for cobra

Functions

This section is empty.

Types

type FileInfo

type FileInfo struct {
	os.FileInfo
}

FileInfo represents info about a file satisfying os.FileInfo and also some additional interfaces for webdav for ETag and ContentType

func (FileInfo) ContentType

func (fi FileInfo) ContentType(ctx context.Context) (contentType string, err error)

ContentType returns a content type for the FileInfo

func (FileInfo) ETag

func (fi FileInfo) ETag(ctx context.Context) (etag string, err error)

ETag returns an ETag for the FileInfo

type Handle

type Handle struct {
	vfs.Handle
}

Handle represents an open file

func (Handle) Readdir

func (h Handle) Readdir(count int) (fis []os.FileInfo, err error)

Readdir reads directory entries from the handle

func (Handle) Stat

func (h Handle) Stat() (fi os.FileInfo, err error)

Stat the handle

type WebDAV

type WebDAV struct {
	*httplib.Server
	// contains filtered or unexported fields
}

WebDAV is a webdav.FileSystem interface

A FileSystem implements access to a collection of named files. The elements in a file path are separated by slash ('/', U+002F) characters, regardless of host operating system convention.

Each method has the same semantics as the os package's function of the same name.

Note that the os.Rename documentation says that "OS-specific restrictions might apply". In particular, whether or not renaming a file or directory overwriting another existing file or directory is an error is OS-dependent.

func (*WebDAV) Mkdir

func (w *WebDAV) Mkdir(ctx context.Context, name string, perm os.FileMode) (err error)

Mkdir creates a directory

func (*WebDAV) OpenFile

func (w *WebDAV) OpenFile(ctx context.Context, name string, flags int, perm os.FileMode) (file webdav.File, err error)

OpenFile opens a file or a directory

func (*WebDAV) RemoveAll

func (w *WebDAV) RemoveAll(ctx context.Context, name string) (err error)

RemoveAll removes a file or a directory and its contents

func (*WebDAV) Rename

func (w *WebDAV) Rename(ctx context.Context, oldName, newName string) (err error)

Rename a file or a directory

func (*WebDAV) Stat

func (w *WebDAV) Stat(ctx context.Context, name string) (fi os.FileInfo, err error)

Stat returns info about the file or directory

Jump to

Keyboard shortcuts

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