Created
May 19, 2022 05:27
-
-
Save Heilum/804660e0b66b60fb3d665c96f0d4dc52 to your computer and use it in GitHub Desktop.
Dart download fragmented file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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