famedlysdk/lib/src/utils/matrix_file.dart

22 lines
612 B
Dart
Raw Normal View History

2020-01-02 14:09:49 +00:00
/// Workaround until [File] in dart:io and dart:html is unified
import 'dart:typed_data';
2020-03-16 10:38:03 +00:00
import 'package:matrix_file_e2ee/matrix_file_e2ee.dart';
2019-10-18 11:05:07 +00:00
class MatrixFile {
Uint8List bytes;
2019-10-18 11:05:07 +00:00
String path;
2020-03-16 10:38:03 +00:00
Future<EncryptedFile> encrypt() async {
print("[Matrix] Encrypt file with a size of ${bytes.length} bytes");
final EncryptedFile encryptedFile = await encryptFile(bytes);
print("[Matrix] File encryption successfull");
this.bytes = encryptedFile.data;
return encryptedFile;
}
2019-10-23 18:14:04 +00:00
MatrixFile({this.bytes, String path}) : this.path = path.toLowerCase();
2019-10-18 11:05:07 +00:00
int get size => bytes.length;
}