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),
);