is it possible to use the installed ContentNegotia...
# ktor
n
is it possible to use the installed ContentNegotiation to parse
FormItem.value
within a multi-part form?
a
Can you please share some code to illustrate your question?
n
i mean when reading data from a multi-part for where you include things like JSON along w/ the file data:
Copy code
val multipartData = call.receiveMultipart()

var itemA: ItemA?     = null
var itemB: ItemB?     = null
var data : ByteArray? = null

multipartData.forEachPart { part ->
    when (part) {
        is FormItem -> {
            when (part.name) {
                "itemA" -> itemA = Json.decodeFromString<ItemA>(part.value) // would be great to use ContentNegotiation here
                "itemB" -> itemB = Json.decodeFromString<ItemB>(part.value) // instead of manually using Json parsing

                // "itemA" -> part.receive<ItemA>()
            }
        }
        is FileItem -> data = part.streamProvider().readAllBytes()
        else        -> {}
    }
    part.dispose()
}

// ...
a
Unfortunately, you can't use the ContentNegotiation plugin that way.
👍 1