Skip to content

Instantly share code, notes, and snippets.

@Heilum
Created May 19, 2022 05:27
Show Gist options
  • Save Heilum/804660e0b66b60fb3d665c96f0d4dc52 to your computer and use it in GitHub Desktop.
Save Heilum/804660e0b66b60fb3d665c96f0d4dc52 to your computer and use it in GitHub Desktop.
Dart download fragmented file
import 'package:http/http.dart';
static Future downloadFragmentedFile(String url, File localFile) async {
final request = Request('get', Uri.parse(url));
request.headers.addAll({"range": "bytes=0-"});
StreamedResponse rs = await Client().send(request);
var fileStream = localFile.openWrite();
await rs.stream.pipe(fileStream);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment