SauceNaoAPI/src/jsMain/kotlin/dev/inmo/saucenaoapi/utils/ActualMPPFile.kt

19 lines
532 B
Kotlin
Raw Normal View History

2022-05-14 07:43:28 +00:00
package dev.inmo.saucenaoapi.utils
import io.ktor.http.ContentType
import io.ktor.utils.io.core.ByteReadPacket
import io.ktor.utils.io.core.Input
import org.khronos.webgl.Int8Array
import org.w3c.files.File
import org.w3c.files.FileReaderSync
actual typealias MPPFile = File
actual val MPPFile.input: Input
get() {
val reader = FileReaderSync()
return ByteReadPacket(Int8Array(reader.readAsArrayBuffer(this)) as ByteArray)
}
actual val MPPFile.contentType: ContentType
get() = ContentType.parse(type)