FileService

interface FileService

This interface defines methods to get files.

Types

Link copied to clipboard
sealed class FileState

Functions

Link copied to clipboard
abstract fun clearCache()

Clears all the files downloaded by the service, including decrypted files.

Link copied to clipboard
abstract fun clearDecryptedCache()

Clears all the decrypted files by the service.

Link copied to clipboard
open suspend fun downloadFile(messageContent: MessageWithAttachmentContent): File

abstract suspend fun downloadFile(    fileName: String,     mimeType: String?,     url: String?,     elementToDecrypt: ElementToDecrypt?): File

Download a file if necessary and ensure that if the file is encrypted, the file is decrypted. Result will be a decrypted file, stored in the cache folder. url parameter will be used to create unique filename to avoid name collision.

Link copied to clipboard
open fun fileState(messageContent: MessageWithAttachmentContent): FileService.FileState

abstract fun fileState(    mxcUrl: String?,     fileName: String,     mimeType: String?,     elementToDecrypt: ElementToDecrypt?): FileService.FileState

Get information on the given file. Mimetype should be the same one as passed to downloadFile (limitation for now)

Link copied to clipboard
abstract fun getCacheSize(): Long

Get size of cached files.

Link copied to clipboard
open fun getTemporarySharableURI(messageContent: MessageWithAttachmentContent): Uri?

abstract fun getTemporarySharableURI(    mxcUrl: String?,     fileName: String,     mimeType: String?,     elementToDecrypt: ElementToDecrypt?): Uri?

Use this URI and pass it to intent using flag Intent.FLAG_GRANT_READ_URI_PERMISSION (if not other app won't be able to access it).

Link copied to clipboard
open fun isFileInCache(messageContent: MessageWithAttachmentContent): Boolean
abstract fun isFileInCache(    mxcUrl: String?,     fileName: String,     mimeType: String?,     elementToDecrypt: ElementToDecrypt?): Boolean