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

  1. import 'dart:io';
  2. import 'package:http/http.dart' as http;
  3. import '/utils/encryption/aes_helper.dart';
  4. import '/utils/storage/session_cookie.dart';
  5. import '/utils/storage/write_file.dart';
  6. Future<File> getFile(String link, String imageName, dynamic symmetricKey) async {
  7. var resp = await http.get(
  8. Uri.parse(link),
  9. headers: {
  10. 'cookie': await getSessionCookie(),
  11. }
  12. );
  13. if (resp.statusCode != 200) {
  14. throw Exception('Could not get attachment file');
  15. }
  16. var data = AesHelper.aesDecryptBytes(
  17. symmetricKey,
  18. resp.bodyBytes,
  19. );
  20. File file = await writeImage(
  21. imageName,
  22. data,
  23. );
  24. return file;
  25. }