diff --git a/features/common/common/src/commonMain/kotlin/dev/inmo/postssystem/features/common/common/SimpleInputProvider.kt b/features/common/common/src/commonMain/kotlin/dev/inmo/postssystem/features/common/common/SimpleInputProvider.kt index 1f571f8b..67cd2830 100644 --- a/features/common/common/src/commonMain/kotlin/dev/inmo/postssystem/features/common/common/SimpleInputProvider.kt +++ b/features/common/common/src/commonMain/kotlin/dev/inmo/postssystem/features/common/common/SimpleInputProvider.kt @@ -11,6 +11,8 @@ import kotlinx.serialization.Serializable @Serializable(SimpleInputProviderSerializer::class) interface SimpleInputProvider { + val contentBytes: Long? + operator fun invoke(): Input } @@ -18,6 +20,8 @@ interface SimpleInputProvider { class BytesBasedInputProvider( private val bytes: ByteArray ) : SimpleInputProvider { + override val contentBytes: Long + get() = bytes.size.toLong() override fun invoke(): Input { return ByteReadPacket(bytes) } diff --git a/features/common/common/src/jsMain/kotlin/dev/inmo/postssystem/features/common/common/FileBasedInputProvider.kt b/features/common/common/src/jsMain/kotlin/dev/inmo/postssystem/features/common/common/FileBasedInputProvider.kt index 11f3c820..2396c976 100644 --- a/features/common/common/src/jsMain/kotlin/dev/inmo/postssystem/features/common/common/FileBasedInputProvider.kt +++ b/features/common/common/src/jsMain/kotlin/dev/inmo/postssystem/features/common/common/FileBasedInputProvider.kt @@ -1,7 +1,6 @@ package dev.inmo.postssystem.features.common.common -import dev.inmo.micro_utils.common.MPPFile -import dev.inmo.micro_utils.common.bytes +import dev.inmo.micro_utils.common.* import io.ktor.utils.io.core.ByteReadPacket import io.ktor.utils.io.core.Input import kotlinx.serialization.Serializable @@ -10,6 +9,9 @@ import kotlinx.serialization.Serializable actual class FileBasedInputProvider internal constructor( actual val file: MPPFile ) : SimpleInputProvider { + override val contentBytes: Long + get() = file.filesize + override fun invoke(): Input = error("Files inputs must not be used directly") } diff --git a/features/common/common/src/jvmMain/kotlin/dev/inmo/postssystem/features/common/common/FileBasedInputProvider.kt b/features/common/common/src/jvmMain/kotlin/dev/inmo/postssystem/features/common/common/FileBasedInputProvider.kt index 8555e390..d072ee8b 100644 --- a/features/common/common/src/jvmMain/kotlin/dev/inmo/postssystem/features/common/common/FileBasedInputProvider.kt +++ b/features/common/common/src/jvmMain/kotlin/dev/inmo/postssystem/features/common/common/FileBasedInputProvider.kt @@ -1,6 +1,7 @@ package dev.inmo.postssystem.features.common.common import dev.inmo.micro_utils.common.MPPFile +import dev.inmo.micro_utils.common.filesize import io.ktor.utils.io.core.Input import io.ktor.utils.io.streams.asInput import kotlinx.serialization.Serializable @@ -9,5 +10,8 @@ import kotlinx.serialization.Serializable actual class FileBasedInputProvider( actual val file: MPPFile ) : SimpleInputProvider { + override val contentBytes: Long? + get() = file.filesize + override fun invoke(): Input = file.inputStream().asInput() }