WebDAV en Javascript

I wrote a small WebDAV javascript librairy based on the prototype framework.

The API is simple :

1
2
3
4
5
6
7
8
9
10
var dav = new DAV('http://someserver/');

var txt = dav.get('somefile.txt');

dav.each('/somedir/', function(name, info) {
console.log(name, info);
});

txt += "\nModified";
dav.put('somefile.txt', txt);

Of course, the Same Origin Policy may limit the sites you can reach. But it work perfectly to get, list and modify files on the same server.

To configure apache to accept DAV requests, just add a Dav On in a <Directory> directive and enable the dav* modules…

While developing this script, I found that Ajax.Request doesn’t allow to make request other than GET and POST. WebDAV need more verbs, like PUT or PROPFIND. So I made a new Ajax.FreeRequest function that doesn’t check the verb used.

The script is licensed under the terms of the GPL V3 and can be downloaded here: dav-0.1.js

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée.

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.