cacheGrpcMedia static method
Save a gRPC MediaItem to the appropriate cache folder
Implementation
static Future<File> cacheGrpcMedia(
MediaItem item,
FileCategory category,
String conversationId,
) async {
final folderPath = await _getFolder(category);
final fileName = Uri.parse(item.fileUrl).pathSegments.last;
final file = File('$folderPath/$fileName');
if (await file.exists()) {
if (kDebugMode) {
print("📦 Loaded from cache: ${file.path}");
}
return file;
}
if (kDebugMode) {
print("💾 Saving gRPC media: ${item.fileUrl}");
}
await file.writeAsBytes(item.content);
return file;
}