Skip to content

Commit

Permalink
Merge pull request CarnegieTechnologies#119 from Letalus/header_branch
Browse files Browse the repository at this point in the history
implements header within saveVideo and saveImage
  • Loading branch information
lecicdjuro authored Sep 20, 2021
2 parents 373ed4f + 33c0234 commit f23b5f9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/gallery_saver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class GallerySaver {
static const MethodChannel _channel = const MethodChannel(channelName);

///saves video from provided temp path and optional album name in gallery
static Future<bool?> saveVideo(String path, {String? albumName}) async {
static Future<bool?> saveVideo(String path, {String? albumName, Map<String, String>? headers}) async {
File? tempFile;
if (path.isEmpty) {
throw ArgumentError(pleaseProvidePath);
Expand All @@ -41,7 +41,7 @@ class GallerySaver {
}

///saves image from provided temp path and optional album name in gallery
static Future<bool?> saveImage(String path, {String? albumName}) async {
static Future<bool?> saveImage(String path, {String? albumName, Map<String, String>? headers}) async {
File? tempFile;
if (path.isEmpty) {
throw ArgumentError(pleaseProvidePath);
Expand All @@ -65,10 +65,10 @@ class GallerySaver {
return result;
}

static Future<File> _downloadFile(String url) async {
static Future<File> _downloadFile(String url, {Map<String, String>? headers}) async {
print(url);
http.Client _client = new http.Client();
var req = await _client.get(Uri.parse(url));
var req = await _client.get(Uri.parse(url), headers: headers);
var bytes = req.bodyBytes;
String dir = (await getTemporaryDirectory()).path;
File file = new File('$dir/${basename(url)}');
Expand Down

0 comments on commit f23b5f9

Please sign in to comment.