Documentation ¶
Overview ¶
Package webdav implements a WebDAV server backed by rclone VFS
Index ¶
- Variables
- type FileInfo
- type Handle
- type Options
- type WebDAV
- func (w *WebDAV) Mkdir(ctx context.Context, name string, perm os.FileMode) (err error)
- func (w *WebDAV) OpenFile(ctx context.Context, name string, flags int, perm os.FileMode) (file webdav.File, err error)
- func (w *WebDAV) RemoveAll(ctx context.Context, name string) (err error)
- func (w *WebDAV) Rename(ctx context.Context, oldName, newName string) (err error)
- func (w *WebDAV) ServeHTTP(rw http.ResponseWriter, r *http.Request)
- func (w *WebDAV) Stat(ctx context.Context, name string) (fi os.FileInfo, err error)
Constants ¶
This section is empty.
Variables ¶
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
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
var Opt = DefaultOpt
Opt is options set by command line flags
Functions ¶
This section is empty.
Types ¶
type FileInfo ¶
FileInfo represents info about a file satisfying os.FileInfo and also some additional interfaces for webdav for ETag and ContentType
func (FileInfo) ContentType ¶
ContentType returns a content type for the FileInfo
type Handle ¶
Handle represents an open file
func (Handle) Patch ¶
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
type Options ¶
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 ¶
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) 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