downloadAndSetInCache function
Future<void>
downloadAndSetInCache(
- String mediaUrl, {
- required GetStorage getStorage,
})
Implementation
Future<void> downloadAndSetInCache(String mediaUrl, {required GetStorage getStorage}) async {
final tmpPath = await downloadMediaToCache(mediaUrl);
if (await doesFileExist(tmpPath)) {
var file = File(tmpPath!);
final cachedMediaInfoToSet = CachedMediaInfo(
id: const Uuid().v1(),
mediaUrl: mediaUrl,
dateCreated: DateTime.now().millisecondsSinceEpoch ~/ 1000,
fileSize: await file.length(),
cachedMediaUrl: tmpPath,
);
addCachedMediaInfo(getStorage, cachedMediaInfoToSet);
}
}