This repository has been archived by the owner on Nov 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Properties
thomasfl edited this page Sep 13, 2010
·
3 revisions
For those not familiar with WebDAV, directories are called collections and files are called resources. Both files and directories have properties that can be read as XML by doing a PROPFIND request to the server, and set by doing a PROPPATCH request. To see the properties for a file, use the dav
command line utility included in the Net::DAV gem. The username and password for the server must be set in the environment variables DAVUSER and DAVPASS.
dav props http://www.example.com/about/index.html
This should print out something like the this.
<?xml version="1.0" encoding="utf-8"?>
<d:multistatus xmlns:d="DAV:">
<d:response>
<d:href>http://www.example.com/about/index.html</d:href>
<d:propstat>
<d:prop>
<d:lockdiscovery/>
<d:supportedlock>
<d:lockentry>
<d:lockscope>
<d:exclusive/>
</d:lockscope>
<d:locktype>
<d:write/>
</d:locktype>
</d:lockentry>
</d:supportedlock>
<d:getcontenttype>text/html</d:getcontenttype>
<d:resourcetype/>
<d:getcontentlength>9152</d:getcontentlength>
<d:getlastmodified>Mon, 30 Nov 2009 21:03:41 GMT</d:getlastmodified>
<d:creationdate>2008-10-17T19:01:29Z</d:creationdate>
<d:getetag>858b88b03c8d8510b31cebf191fc42a2</d:getetag>
<d:displayname>index.html</d:displayname>
</d:prop>
<d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>
</d:response>
</d:multistatus>
These properties can be set like this.
require 'rubygems'
require 'net/dav'
dav = Net::DAV.new('http://www.example.com/')
dav.credentials(ENV['DAVUSER'],ENV['DAVPASS'])
dav.proppatch('about/index.html','<d:resourcetype>text/html</d:resourcetype>')