WebDAV html 源码,webdavjs: WebDAV.js 是一个简单的 WebDAV 协议的 JavaScript 实现,目前还没有完成整个协议的支持,只支持基本的操作...

WebDAV.js

This is a simple JavaScript library that attempts to implement a subset of the

WebDAV standard. It (currently) doesn’t aim to be complete – just support basic

operations.

WebDAV.js has a low-level API (the WebDAV object) and a higher level, more OO API

(WebDAV.Fs).

Both APIs can operate in synchronous and asynchronous mode: All functions that

declare a callback argument accept an optional function. If a callback function is

passed, the HTTP request will happen asynchronously, passing the result to that

function. If no callback function is passed, the result is returned directly after

the synchronous HTTP request.

For each function – “result” refers to either the function’s return value or the

argument passed to the callback function (if any).

WebDAV

This is a very thin wrapper around XMLHttpRequest.

WebDAV.Fs

This is the entry point to the OO interface. Create a new instance like this:

var fs = new WebDAV.Fs(url);

A WebDAV.Fs object has 2 methods:

dir(url) – returns a Dir object

file(url) – returns a File object

The url argument can be an absulute or relative URL. Example:

var fs = new WebDAV.Fs('http://localhost:1234/my_files');

var hello = fs.file('/my/hello.txt');

// This is the same as:

var hello = fs.file('http://localhost:1234/my_files/my/hello.txt');

File.read(callback)

Reads the file and passes the contents to the result.

File.write(data, callback)

Writes data to the file.

File.rm(callback)

Deletes the file.

Dir.children(callback)

Lists all files and directories under Dir. The result is an Array of other File

and/or Dir objects.

Dir.mkdir(callback)

Creates the directory.

Dir.rm(callback)

Removes the directory.

Usage/Example

Check out example/index.html

To see it in action in a browser, stand in the root folder and run:

ruby spec/webdav_server.rb

Then point your browser to http://localhost:10080/example/index.html

You should be able to browse and edit everything from within your browser.

Running tests

You need to download some tools. Run ./install_tools.sh to pull them down.

In shell A

ruby spec/webdav_server.rb spec/fixtures

In shell B

ant jsspec

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值