FLUTTER ECOSYSTEM

Taskulu/chunked_uploader

一个将文件分块上传到服务器的插件。

chunked_uploader 项目封面
Stars
24
Forks
9
最近推送(UTC)
2024年3月12日
项目状态
未归档
Taskulu GitHub avatar
GITHUB Organization

Taskulu ↗

语言Dart

此仓库发布的插件

使用的依赖

依赖清单 3 项

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

展开 / 收起项目 README

Chunked Uploader

A plugin to upload files to server in chunks.

pub package

Usage

To use this plugin, add chunked_uploader as dependency in your pubspec.yaml file.

dependencies:
  flutter:
    sdk: flutter
  chunked_uploader: ^1.0.0
  file_picker: ^5.2.5
  dio: ^4.0.6

Example

final file =
    (await FilePicker.platform.pickFiles(withReadStream: true))!.files.single;
final dio = Dio(BaseOptions(
  baseUrl: 'https://example.com/api',
  headers: {'Authorization': 'Bearer'},
));
final uploader = ChunkedUploader(dio);

// using data stream
final response = await uploader.upload(
  fileName: file.name,
  fileSize: file.size,
  fileDataStream: file.readStream!,
  maxChunkSize: 500000,
  path: '/file',
  onUploadProgress: (progress) => print(progress),
);
// using path
final response = await uploader.uploadUsingFilePath(
  fileName: file.name,
  filePath: file.path!,
  maxChunkSize: 500000,
  path: '/file',
  onUploadProgress: (progress) => print(progress),
);