搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案