StreamFileManager

Manages file operations for the Stream Chat SDK, providing utilities for caching, retrieving, and managing files in various cache directories and external storage.

This class handles:

  • Image caching in a dedicated directory

  • General file caching in the Stream cache directory

  • Timestamped cache folders for isolated file storage

  • Cache cleanup operations

  • External storage management for photos and videos captured using the SDK

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun clearAllCache(context: Context): Result<Unit>

Clears all cached data including Stream cache, image cache, and timestamped cache folders.

Link copied to clipboard
fun clearCache(context: Context): Result<Unit>

Clears the Stream cache directory.

Link copied to clipboard
fun clearExternalStorage(context: Context): Result<Unit>

Clears Stream files from the external storage directories.

Link copied to clipboard
fun createFileInCache(context: Context, fileName: String): Result<File>

Creates a file reference in cache without writing content.

Link copied to clipboard
fun createPhotoInExternalDir(context: Context): Result<File>

Creates a file for photo capture in the external pictures directory.

Link copied to clipboard
fun createVideoInExternalDir(context: Context): Result<File>

Creates a file for video capture in the external movies directory.

Link copied to clipboard
suspend fun getFileFromCache(context: Context, fileName: String): Result<File>

Retrieves a file from cache by name.

Link copied to clipboard
fun getImageCache(context: Context): File

Returns the directory used for caching images.

Link copied to clipboard
suspend fun writeFileInCache(context: Context, fileName: String, source: InputStream): Result<File>

Writes data from an InputStream to a cache file.

Link copied to clipboard
fun writeFileInTimestampedCache(context: Context, fileName: String, source: InputStream): Result<File>

Writes data from an InputStream to a file in a timestamped cache folder.