MediaStorageService class
Manages media file storage, hashing, thumbnailing, and pruning.
Obtain via GetIt:
final mediaStorage = getIt<MediaStorageService>();
Constructors
- MediaStorageService({required AirpassDatabase database})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
computeHash(
String filePath) → Future< String> -
Computes the SHA-256 hash of a file at
filePath. -
computeHashFromBytes(
Uint8List bytes) → String - Computes SHA-256 hash from raw bytes.
-
deleteMedia(
String messageId) → Future< void> - Deletes all media files associated with a message.
-
generateThumbnail(
Uint8List imageBytes) → Future< Uint8List?> - Generates a compressed JPEG thumbnail from image bytes.
-
getMediaFilePath(
String messageId, String fileName) → Future< String> - Returns the intended absolute path for a specific media file.
-
getMediaPath(
String messageId) → Future< String?> - Returns the local file path for a message's media, or null if the file doesn't exist on disk.
-
getTotalMediaSize(
) → Future< int> - Returns the total size of all stored media files (bytes). Useful for displaying storage usage in settings.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pruneOrphanedMedia(
) → Future< int> - Prunes media files whose messages no longer exist in the database.
-
readMedia(
String messageId) → Future< Uint8List?> - Reads the raw bytes of a stored media file.
-
saveMedia(
{required String messageId, required Uint8List bytes, required String fileName}) → Future< String> - Saves a media file to local storage.
-
saveMediaFromPath(
{required String messageId, required String sourcePath, required String fileName}) → Future< String> - Saves a media file from a source path (move/copy).
-
toString(
) → String -
A string representation of this object.
inherited
-
verifyHash(
String filePath, String expectedHash) → Future< bool> - Verifies a file's integrity against an expected SHA-256 hash.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited