Encrypted messaging app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
648 B

import 'dart:io';
import 'package:http/http.dart' as http;
import '/utils/encryption/aes_helper.dart';
import '/utils/storage/session_cookie.dart';
import '/utils/storage/write_file.dart';
Future<File> getFile(String link, String imageName, dynamic symmetricKey) async {
var resp = await http.get(
Uri.parse(link),
headers: {
'cookie': await getSessionCookie(),
}
);
if (resp.statusCode != 200) {
throw Exception('Could not get attachment file');
}
var data = AesHelper.aesDecryptBytes(
symmetricKey,
resp.bodyBytes,
);
File file = await writeImage(
imageName,
data,
);
return file;
}