title: check whether all parameter exist or not in multipart request body with ktor
body: <p>I am trying to create a multipart request with ktor, whose code is as follows,</p>
  <pre><code>import com.firstapp.modal.response.SuccessResponse
  import io.ktor.application.call
  import io.ktor.http.HttpStatusCode
  import io.ktor.http.content.PartData
  import io.ktor.http.content.forEachPart
  import io.ktor.http.content.streamProvider
  import io.ktor.locations.Location
  import io.ktor.locations.post
  import io.ktor.request.isMultipart
  import io.ktor.request.receive
  import io.ktor.request.receiveMultipart
  import io.ktor.response.respond
  import io.ktor.routing.Route
  import io.ktor.util.getOrFail
  import kotlinx.coroutines.CoroutineDispatcher
  import kotlinx.coroutines.Dispatchers
  import kotlinx.coroutines.withContext
  import kotlinx.coroutines.yield
  import java.io.File
  import java.io.InputStream
  import java.io.OutputStream
  import java.lang.IllegalArgumentException
  
  @Location(&quot;/uploadVideo/{title}&quot;)
  class UploadVideo(val title:String)
  
  fun Route.upload(uploadDir: File) {
  
      post&lt;UploadVideo&gt; {
          val multipart = call.receiveMultipart()
          var videoFile: File? = null
  
          // Processes each part of the multipart input content of the user
          multipart.forEachPart { part -&gt;
              when (part) {
                  is PartData.FormItem -&gt; {
                      if (part.name != &quot;title&quot;)
                          throw IllegalArgumentException(&quot;Title parameter not found&quot;)
                      //title = part.value
                  }
                  is PartData.FileItem -&gt; {
                      if (part.name != &quot;file&quot;)
                          throw IllegalArgumentException(&quot;file parameter not found&quot;)
  
                      val ext = File(part.originalFileName).extension
                      val file = File(uploadDir, &quot;upload-${System.currentTimeMillis()}-${call.parameters.getOrFail(&quot;title&quot;).hashCode()}.$ext&quot;)
                      part.streamProvider().use { input -&gt; file.outputStream().buffered().use { output -&gt; input.copyToSuspend(output) } }
                      videoFile = file
                  }
              }
  
              part.dispose()
          }
  
          call.respond(
              HttpStatusCode.OK,
              SuccessResponse(
                  videoFile!!,
                  HttpStatusCode.OK.value,
                  &quot;video file stored&quot;
              )
          )
      }
  }
  
  
  suspend fun InputStream.copyToSuspend(
      out: OutputStream,
      bufferSize: Int = DEFAULT_BUFFER_SIZE,
      yieldSize: Int = 4 * 1024 * 1024,
      dispatcher: CoroutineDispatcher = Dispatchers.IO
  ): Long {
      return withContext(dispatcher) {
          val buffer = ByteArray(bufferSize)
          var bytesCopied = 0L
          var bytesAfterYield = 0L
          while (true) {
              val bytes = read(buffer).takeIf { it &gt;= 0 } ?: break
              out.write(buffer, 0, bytes)
              if (bytesAfterYield &gt;= yieldSize) {
                  yield()
                  bytesAfterYield %= yieldSize
              }
              bytesCopied += bytes
              bytesAfterYield += bytes
          }
          return@withContext bytesCopied
      }
  }
  </code></pre>
  <p>The above code or rest api is working fine but the issue is that, i want to check, whether all parameters are available or not i.e. i want to send additional parameters along with file in format as follows,</p>
  <pre><code>class VideoDetail(val type: String, val userId: String, val userName: String)
  </code></pre>
  <p>I am giving here an example, what i want i.e.</p>
  <pre><code>post(&quot;/&quot;) { request -&gt;
      val requestParamenter = call.receive&lt;UserInsert&gt;()
  }
  </code></pre>
  <p>here, whatever the paramenters, we pass will automatically get converted into pojo classes, and if we hadn't passed it, it will throw exception,</p>
  <p>So, the similar thing i want to achieve with multipart.</p>