2020-01-02 14:09:49 +00:00
|
|
|
/// Workaround until [File] in dart:io and dart:html is unified
|
2020-02-24 16:54:43 +00:00
|
|
|
|
|
|
|
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 {
|
2020-02-24 16:54:43 +00:00
|
|
|
Uint8List bytes;
|
2019-10-18 11:05:07 +00:00
|
|
|
String path;
|
|
|
|
|
2020-03-23 09:37:51 +00:00
|
|
|
/// Encrypts this file, changes the [bytes] and returns the
|
|
|
|
/// encryption information as an [EncryptedFile].
|
2020-03-16 10:38:03 +00:00
|
|
|
Future<EncryptedFile> encrypt() async {
|
2020-03-30 09:08:38 +00:00
|
|
|
var encryptFile2 = encryptFile(bytes);
|
|
|
|
final encryptedFile = await encryptFile2;
|
|
|
|
bytes = encryptedFile.data;
|
2020-03-16 10:38:03 +00:00
|
|
|
return encryptedFile;
|
|
|
|
}
|
|
|
|
|
2020-03-30 09:08:38 +00:00
|
|
|
MatrixFile({this.bytes, String path}) : path = path.toLowerCase();
|
2019-10-18 11:05:07 +00:00
|
|
|
int get size => bytes.length;
|
|
|
|
}
|