writeFileInTimestampedCache

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

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

This method creates a unique timestamped folder (format: STREAM_HHmmssSSS) and writes the file there. This is useful for caching files from URIs where unique folder isolation is needed to prevent naming conflicts.

Return

Result.Success with the cached File, or Result.Failure with an error

Parameters

context

Android context for cache directory access

fileName

Name of the file to create in the timestamped folder

source

InputStream containing the data to cache