WebDAV Interface



Introduction

Each WebPal server comes by default WebDAV-enabled. WebDAV is a service that allows access and modification of remote resources, through a set of extensions of the HTTP/1.1 protocol. WebDAV is defined in RFC 4918. Originally incepted to allow remote Web content authoring operations, it can also be used to allow remote operations on any remote resource.

Modern operating systems like Windows, OS X, and some Linux distributions have WebDAV capabilities built-in, allowing users to mount WebDAV shares on their system and access them as if they were a local resource. On mobile devices running Android or iOS, there are also WebDAV clients to access your documents. This enables any user to truly access their WebPal documents on any device.

For the developer, this does not only mean ease of access to remote resources, this means scripting. Scripts can be written to watch a local directory for any new files, and upload those to the DM. Or to watch a folder on the DM for new files and download those to the local machine. Or both, to accomplish a two-way sync.

There are many tools out there allowing users to connect to a WebDAV-enabled server and execute commands. Some notable resources:

  • cadaver, a command-line client. A user can connect to a WebDAV server and execute local and remote commands in a REPL environment.
  • cURL, a Unix command to transfer data to and from a server. It supports HTTP, so by extension it supports WebDAV.
  • easywebdav, a python library. This can be used to integrate WebDAV into new or existing python scripts.
  • sabreDAV, a PHP library. This can be used to integrate WebDAV into new or existing PHP applications.
  • DavFS, a Linux filesystem driver. This enables you to mount WebDAV shares as disk drives on your Linux machine.
  • and many more...

This guide will focus on connecting to WebPal using cadaver.

Cadaver

Looking at the cadaver man page, we see that cadaver has a total of 34 commands. Check the man page for a full listing of the commands and their operations.

A quick overview of WebDAV commands implemented in the current version of WebPal is given here:

Command Usage Description
open

close
open https://demo026.webpal.net/webdav

close
The open command connects to a WebDAV resource. You will be prompted for your WebPal username and password. Alternatively, you can specify your credentials in a .netrc file to automate authentication. Use the close command to disconnect from the resource.
ls
cd
pwd 
less 
cat
ls "System Drive" 
cd "System Drive/Documents" 
pwd 
less "System Drive/Documents/example.html" 
cat "System Drive/Documents/README"
These commands operate the same as their Unix counterparts, but are run against the remote resource.
lls 
lcd 
lpwd
lls "/path/to/local/dir" 
lcd "/path/to/other/dir" 
lpwd
These commands are the same as the Unixlscd, and pwd, and operate on thelocal system.
put 
mput
put koala.jpg "System Drive/Animals/koala.jpg" 
mput koala.jpg tiger.jpg penguin.jpg "System Drive/Animals/"
The put and mput commands will upload the specified local file, or multiple local files, to the remote resource.
get 
mget
get "System Drive/Animals/palomino.jpg" ~/animals/ 
mget palomino.jpg kangaroo.jpg monkey.jpg ~/animals/
The get and mget commands will download the specified remote resource, or multiple remote resources, to the local system.
mkcol mkcol "System Drive/New Folder" mkcol will attempt to create a collection at the specified remote resource, similar to the Unix mkdir command.
delete 
rmcol
delete "System Drive/Animals/monkey.jpg" 
rmcol "System Drive/Animals"
delete and rmcol are used to delete remote resources and collections, respectively. These are similar to the Unixrm and rmdir commands.
copy 
move
copy "System Drive/Animals/*" "System Drive/Backups/Animals/" 
move "System Drive/Private/V_2.1_dev" "System Drive/Public/V_2.1"
The copy and move can be used to copy/move resources and collections on the remote resource.
propnames
propget
propnames "System Drive/README.txt" 
propget "/System Drive/README.txt"
The propnames command will return all of the property names for a given resource. The propget command will return the property names and their values for the given resource. The properties of a resource can be thought of as metadata.
quit quit Exit the program
help help Displays a help message with possible commands

Example Cadaver Session

Here is an example interactive session where we connect to the WebPal server and try out some common commands.

user@hostname$ cadaver https://demo026.webpal.net/webdav
Authentication required for dm@palominosys.com on server `myserver.webpal.net':
Username: myusername
Password:
dav:/webdav/> ls "System Drive"

#Now that we are connected to the server, we will try to upload a file
dav:/webdav/> cd "System Drive"
dav:/webdav/System Drive/> mkcol example
Creating `example': succeeded.
dav:/webdav/System Drive/> ls
Listing collection `/webdav/System%20Drive/': succeeded.
Coll:   Animals                                 0 Apr 24 15:22
Coll:   Documents                               0 Apr 23 16:53
Coll:   example                                 0 May 14 14:10
        README.txt                           1721 Apr  2 10:00
dav:/webdav/System Drive/> cd example
dav:/webdav/System Drive/example/> lcd local_example
dav:/webdav/System Drive/example/> lls
animals     TestFile.txt
dav:/webdav/System Drive/example/> put TestFile.txt
Uploading TestFile.txt to `/webdav/System%20Drive/example/TestFile.txt':
Progress: [=============================>] 100.0% of 48 bytes succeeded.
dav:/webdav/System Drive/example/> ls
Listing collection `/webdav/System%20Drive/example': succeeded.
        TestFile.txt                           48 May 14 14:14
dav:/webdav/System Drive/example/> cat TestFile.txt
Displaying `/webdav/System%20Drive/example/TestFile.txt':

This is the contents of the test file.
dav:/webdav/System Drive/example/> propget TestFile.txt
Fetching properties for `TestFile.txt':
DAV: getlastmodified = Thu, 14 May 2015 14:14:12 EST
DAV: getcontentlength = 48
DAV: resourcetype =
DAV: getetag = "6966541855252232.   1431626832"
DAV: getcontenttype = text/plain

#Downloading a file
dav:/webdav/System Drive/example/> cd ..
dav:/webdav/System Drive/> get README.txt
Downloading `/webdav/System%20Drive/TestFile.txt' to TestFile.txt:
Progress: [=============================>] 100.0% of 48 bytes succeeded.
dav:/webdav/System Drive/> lls -al README.txt
-rw-r--r-- 1 user group 1721 May 14 14:21 README.txt
dav:/webdav/System Drive/>

#And finally, disconnecting from the server:
dav:/webdav/System Drive/> close
Connection to `myserver.webpal.net' closed.
dav:!> quit
user@hostname$