vibe_large_file_downloader 0.1.1
vibe_large_file_downloader: ^0.1.1 copied to clipboard
Downloads large files to disk in chunks, with resume, progress, cancel and size and checksum verification before the file is put in place.
example/vibe_large_file_downloader_example.dart
import 'package:vibe_large_file_downloader/vibe_large_file_downloader.dart';
Future<void> main() async {
final downloader = Downloader(); // SHA-256 by default
final spec = FetchSpec(
url: 'https://example.com/file.bin',
bytes: 1048576,
digest: 'replace-with-the-published-sha256',
);
try {
final r = await downloader.download(
spec,
'/tmp/file.bin',
onProgress: (got, total) => print('${(100 * got / total).round()}%'),
);
print('saved ${r.file.path}, verified: ${r.verified}');
} on FetchError catch (e) {
print(
'failed: ${e.code.name}'); // network, size, hash, cancelled, notAFile, missing
} finally {
downloader.close();
}
}