搜尋套件、儲存庫與 APP 分類

套件詳情v1.8.3

flutter_onedrive

上傳/下載檔案至/從 OneDrive

AndroidiOSmacOSWindows
近 30 天下載
568
喜歡數
27
Pub 分數
140

安裝套件

flutter pub add flutter_onedrive

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 套件,可實現與 Microsoft OneDrive 之間的無縫檔案上傳和下載。它為在 Android、iOS、macOS 和 Windows 上的 Flutter 應用中整合 OneDrive 雲端儲存提供簡單直觀的介面。該套件透過 OAuth 2.0 處理驗證,並支援對 OneDrive 資料夾中的檔案進行建立、讀取、更新和刪除等作業。非常適合需要在 Microsoft 生態系統中實作安全雲端檔案管理的應用。

適用情境

  • 檔案備份和同步
  • 基於雲的文件共享
  • 使用者資料數據儲存
  • 與 Microsoft Office 工作流程整合
  • 離線優先的應用程式資料持久化

主要特色

  • OneDrive OAuth 2.0 認證
  • 跨平台支援(Android、iOS、macOS、Windows)
  • 檔案上傳和下載方法
  • 資料夾導航和管理
  • 網路和權限問題的錯誤處理

適合對象

  • 需要雲端檔案存取的應用程式
  • 使用 Microsoft 服務的開發人員
  • 需要安全文件儲存的產品
  • 教育或企業應用
  • 行動和桌面混合應用程式

使用建議

  • 需要正確的 OneDrive API 權限
  • 需要使用者同意才能進行OAuth流程
  • 可能需要後端來刷新令牌
  • 僅限 OneDrive 特定功能
  • 依賴互聯網連接

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Features

  • Download files from onedrive
  • Upload files to onedrive
  • List files
  • Create directory
  • Delete files

References

Read below documents before you start using this library:

  • https://docs.microsoft.com/en-us/onedrive/developer/rest-api/getting-started/app-registration?view=odsp-graph-online
  • https://docs.microsoft.com/en-us/onedrive/developer/rest-api/getting-started/msa-oauth?view=odsp-graph-online
  • https://learn.microsoft.com/en-us/onedrive/developer/rest-api/concepts/special-folders-appfolder?view=odsp-graph-online
  • https://github.com/LinusU/flutter_web_auth

Getting started

flutter public add flutter_onedrive
import 'package:flutter_onedrive/flutter_onedrive.dart';

Usage

final onedrive = OneDrive(redirectURL: "your redirect URL", clientID: "your client id");

return FutureBuilder(
  future: onedrive.isConnected(),
  builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
    if (!snapshot.hasData) {
      return const Center(child: CircularProgressIndicator());
    }
    if (snapshot.data ?? false) {
      // Has connected
      return const Text("Connected");
    } else {
      // Hasn't connected
      return MaterialButton(
        child: const Text("Connect"),
        onPressed: () async {
          final success = await onedrive.connect(context);
          if (success) {
            // Create directories
            OneDriveResponse response = await onedrive.createDirectory("/test");
            
            // Upload files
            const str = "Hello, World!";
            var data = Uint8List.fromList(utf8.encode(str));
            response = await onedrive.push(data, "/test/hello.txt");
            
            // Download files
            response = await onedrive.pull("/test/hello.txt");

            // List files
            final files = await onedrive.listFiles("/test/");

            // Delete files
            response = await onedrive.deleteFile("/test/hello.txt");

            // Delete directories
            response = await onedrive.deleteFile("/test");
          }
        },
      );
    }
  },
);

所屬分類

依賴

依賴清單 5 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。