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