搜索插件、代码仓与 APP 分类

插件详情v1.2.2

webdav_client

一个简单的 WebDAV 客户端,支持一些常用方法。

AndroidiOSmacOSWindowsLinux
近 30 天下载
2.3万
喜欢数
63
Pub 分数
130

安装插件

flutter pub add webdav_client

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个轻量级的 WebDAV 客户端,适用于 Flutter 应用程序,通过常见的 HTTP 方法(如 GET、PUT、POST 和 DELETE)与 WebDAV 服务器进行交互。它简化了文件管理任务,例如上传、下载和列出远程服务器上的文件。专为跨平台使用而设计,支持 Android、iOS、macOS、Windows 和 Linux。该包非常适合需要云存储集成或远程文件访问且无需复杂设置的应用程序。其简洁的 API 使开发者能够轻松实现可靠的 WebDAV 连接。

适合场景

  • 云文件同步
  • 远程文件管理
  • 文档存储集成
  • 备份系统
  • 协作文档访问

主要特点

  • 支持标准WebDAV方法
  • 跨平台兼容性
  • 简单直观的 API
  • 安全的身份验证处理
  • 轻量且依赖极少

适合对象

  • 开发以文件为中心的应用程序的开发者
  • 需要云存储访问权限的应用程序
  • 使用 WebDAV 服务器的项目
  • 集成远程文件系统的团队

使用建议

  • 仅限基本的 WebDAV 操作
  • 无内置缓存或离线支持
  • 身份验证必须由外部处理
  • 不适合高性能批量传输

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

webdav_client

A dart WebDAV client library(support null-safety), use dio as http client.

pub.dev link

Main features


web support

see stackoverflow for CORSB problems needing attention

web

Usage

First of all you should create client instance using newClient() function:

var client = newClient(
    'http://localhost:6688/',
    user: 'flyzero',
    password: '123456',
    debug: true,
  );
Common settings
    // Set the public request headers
    client.setHeaders({'accept-charset': 'utf-8'});

    // Set the connection server timeout time in milliseconds.
    client.setConnectTimeout(8000);

    // Set send data timeout time in milliseconds.
    client.setSendTimeout(8000);

    // Set transfer data time in milliseconds.
    client.setReceiveTimeout(8000);

    // Test whether the service can connect
    try {
      await client.ping();
    } catch (e) {
      print('$e');
    }
Read all files in a folder
    var list = await client.readDir('/');
    list.forEach((f) {
        print('${f.name} ${f.path}');
      });

    // can sub folder
    var list2 = await client.readDir('/sub/sub/folder');
    list2.forEach((f) {
        print('${f.name} ${f.path}');
      });
    
Create folder
    await client.mkdir('/新建文件夹');

    // Recursively create folders
    await client.mkdirAll('/new folder/new folder2');
Remove a folder or file

If you remove the folder, some webdav services require a '/' at the end of the path.

    // Delete folder
    await client.remove('/new folder/new folder2/');

    // Delete file
    await client.remove('/new folder/新建文本文档.txt');
Rename a folder or file

If you rename the folder, some webdav services require a '/' at the end of the path.

    // Rename folder
    await client.rename('/新建文件夹/', '/新建文件夹2/', true);

    // Rename file
    await client.rename('/新建文件夹2/test.dart', '/新建文件夹2/test2.dart', true);
Copy a file / folder from A to B

If copied the folder (A > B), it will copy all the contents of folder A to folder B.

Some webdav services have been tested and found to delete the original contents of the B folder!!!

    // Copy all the contents of folderA to folder B
    await client.copy('/folder/folderA/', '/folder/folderB/', true);

    // Copy file
    await client.copy('/folder/aa.png', '/folder/bb.png', true);
Download file
    // download bytes
    await client.read('/folder/folder/openvpn.exe', onProgress: (c, t) {
        print(c / t);
      });

    // download 2 local file with stream 
    await client.read2File(
          '/folder/vpn.exe', 'C:/Users/xxx/vpn2.exe', onProgress: (c, t) {
        print(c / t);
      });
Upload file
    // upload local file 2 remote file with stream
    CancelToken c = CancelToken();
    await client.writeFromFile(
        'C:/Users/xxx/vpn.exe', '/f/vpn2.exe', onProgress: (c, t) {
        print(c / t);
      }, cancelToken: c);
Cancel request
    CancelToken cancel = CancelToken();

    // Supports most methods
    client.mkdir('/新建文件夹', cancel)
    .catchError((err) {
      prints(err.toString());
    });

    // in other
    cancel.cancel('reason')

所属分类

依赖

依赖清单 3 项

源码仓库

使用此插件的项目