webdav

package
v1.66.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: MIT Imports: 26 Imported by: 2

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: `Run a basic WebDAV server to serve a 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 the [hashsum](/commands/rclone_hashsum/) command
to see the full list.

### Access WebDAV on Windows
WebDAV shared folder can be mapped as a drive on Windows, however the default settings prevent it.
Windows will fail to connect to the server using insecure Basic authentication.
It will not even display any login dialog. Windows requires SSL / HTTPS connection to be used with Basic.
If you try to connect via Add Network Location Wizard you will get the following error:
"The folder you entered does not appear to be valid. Please choose another".
However, you still can connect if you set the following registry key on a client machine:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WebClient\Parameters\BasicAuthLevel to 2.
The BasicAuthLevel can be set to the following values:
    0 - Basic authentication disabled
    1 - Basic authentication enabled for SSL connections only
    2 - Basic authentication enabled for SSL connections and for non-SSL connections
If required, increase the FileSizeLimitInBytes to a higher value.
Navigate to the Services interface, then restart the WebClient service.

### Access Office applications on WebDAV
Navigate to following registry HKEY_CURRENT_USER\Software\Microsoft\Office\[14.0/15.0/16.0]\Common\Internet
Create a new DWORD BasicAuthLevel with value 2.
    0 - Basic authentication disabled
    1 - Basic authentication enabled for SSL connections only
    2 - Basic authentication enabled for SSL and for non-SSL connections

https://learn.microsoft.com/en-us/office/troubleshoot/powerpoint/office-opens-blank-from-sharepoint

` + libhttp.Help(flagPrefix) + libhttp.TemplateHelp(flagPrefix) + libhttp.AuthHelp(flagPrefix) + vfs.Help + proxy.Help,
	Annotations: map[string]string{
		"versionIntroduced": "v1.39",
		"groups":            "Filter",
	},
	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)
		}
		Opt.HashType = hash.None
		if Opt.HashName == "auto" {
			Opt.HashType = f.Hashes().GetOne()
		} else if Opt.HashName != "" {
			err := Opt.HashType.Set(Opt.HashName)
			if err != nil {
				return err
			}
		}
		if Opt.HashType != hash.None {
			fs.Debugf(f, "Using hash %v for ETag", Opt.HashType)
		}
		cmd.Run(false, false, command, func() error {
			s, err := newWebDAV(context.Background(), f, &Opt)
			if err != nil {
				return err
			}
			err = s.serve()
			if err != nil {
				return err
			}
			defer systemd.Notify()()
			s.Wait()
			return nil
		})
		return nil
	},
}

Command definition for cobra

View Source
var DefaultOpt = Options{
	Auth:          libhttp.DefaultAuthCfg(),
	HTTP:          libhttp.DefaultCfg(),
	Template:      libhttp.DefaultTemplateCfg(),
	HashType:      hash.None,
	DisableGETDir: false,
}

DefaultOpt is the default values used for Options

Opt is options set by command line flags

Functions

This section is empty.

Types

type FileInfo

type FileInfo struct {
	os.FileInfo
	// contains filtered or unexported fields
}

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
	// contains filtered or unexported fields
}

Handle represents an open file

func (Handle) DeadProps added in v1.63.0

func (h Handle) DeadProps() (map[xml.Name]webdav.Property, error)

DeadProps returns extra properties about the handle

func (Handle) Patch added in v1.63.0

func (h Handle) Patch(proppatches []webdav.Proppatch) ([]webdav.Propstat, error)

Patch changes modtime of the underlying resources, it returns ok for all properties, the error is from setModtime if any FIXME does not check for invalid property and SetModTime error

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 Options added in v1.61.0

type Options struct {
	Auth          libhttp.AuthConfig
	HTTP          libhttp.Config
	Template      libhttp.TemplateConfig
	HashName      string
	HashType      hash.Type
	DisableGETDir bool
}

Options required for http server

type WebDAV

type WebDAV struct {
	*libhttp.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) ServeHTTP added in v1.61.0

func (w *WebDAV) ServeHTTP(rw http.ResponseWriter, r *http.Request)

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