2023-05-17 10:32:23 -04:00
|
|
|
|
|
|
|
import 'dart:typed_data';
|
|
|
|
|
2023-09-30 06:22:32 -04:00
|
|
|
import 'package:contacts_plus_plus/models/records/resonite_db_asset.dart';
|
2023-05-17 10:32:23 -04:00
|
|
|
import 'package:path/path.dart';
|
|
|
|
|
|
|
|
class AssetDigest {
|
|
|
|
final Uint8List data;
|
2023-09-29 03:51:46 -04:00
|
|
|
final ResoniteDBAsset asset;
|
2023-05-17 10:32:23 -04:00
|
|
|
final String name;
|
|
|
|
final String dbUri;
|
|
|
|
|
|
|
|
AssetDigest({required this.data, required this.asset, required this.name, required this.dbUri});
|
|
|
|
|
|
|
|
static Future<AssetDigest> fromData(Uint8List data, String filename) async {
|
2023-09-29 03:51:46 -04:00
|
|
|
final asset = ResoniteDBAsset.fromData(data);
|
2023-05-17 10:32:23 -04:00
|
|
|
|
|
|
|
return AssetDigest(
|
|
|
|
data: data,
|
|
|
|
asset: asset,
|
|
|
|
name: basenameWithoutExtension(filename),
|
2023-09-29 03:51:46 -04:00
|
|
|
dbUri: "resdb:///${asset.hash}${extension(filename)}",
|
2023-05-17 10:32:23 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|