v1.1.0
chunked_uploader
一個易於使用的套件,使用 Dio 在行動裝置、桌面和網頁上以區塊方式上傳檔案。
35喜歡 623近 30 天下載150Pub 分數
AndroidiOSmacOSWindowsLinux
一個將檔案分塊上傳到伺服器的外掛程式。
>=4.0.0 <6.0.0^2.2.2^2.11.0以下為英文專案原文快照,最新內容請造訪 GitHub。
A plugin to upload files to server in chunks.
pub package
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
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),
);