Код: Выделить всё
@Throws(IOException::class)
fun Uri.getByteArrayStringFromUri(context: Context): String {
val iStream: InputStream? = context.contentResolver.openInputStream(this)
val imageByteArray: ByteArray? = iStream?.readBytes()
iStream?.close()
return Base64.getEncoder().encodeToString((Binary(BsonBinarySubType.BINARY, imageByteArray).data))
}
Я также могу поставить растровый карту вместо URI и, возможно, изменить размер в памяти?
Подробнее здесь: https://stackoverflow.com/questions/797 ... droid-kotl
Мобильная версия