搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目

暂无相关数据。