feat: enhance message encryption and media file conversion with improved compression and base64 encoding

This commit is contained in:
2026-02-15 15:45:56 +05:00
parent b543ef4d6f
commit 185ae3ad1d
2 changed files with 16 additions and 11 deletions

View File

@@ -165,15 +165,16 @@ object MediaUtils {
*/
suspend fun uriToBase64File(context: Context, uri: Uri): String? = withContext(Dispatchers.IO) {
try {
val inputStream = context.contentResolver.openInputStream(uri)
val inputStream = context.contentResolver.openInputStream(uri)
?: return@withContext null
val bytes = inputStream.readBytes()
inputStream.close()
val base64 = Base64.encodeToString(bytes, Base64.NO_WRAP)
val mimeType = context.contentResolver.getType(uri) ?: "application/octet-stream"
val base64 = "data:$mimeType;base64," + Base64.encodeToString(bytes, Base64.NO_WRAP)
base64
} catch (e: Exception) {
null