title: Post request with an image using Ktor client
body: <p>I'm having trouble sending an http request which has a File as one of the parameters in the body. The response returned by the API is not what I'm expecting so I figure something is wrong with the code.</p>
  
  <pre><code>suspend fun post(url: String, bodyParameters: MutableMap&lt;String, Any&gt;, headerParameters:
      MutableMap&lt;String, String&gt;? = null): HttpResponse?{
  
          val client = HttpClient()
  
          try {
              val call = client.call(url) {
                  method = HttpMethod.Post
                  body = MultiPartFormDataContent(
                      formData {
                          bodyParameters.forEach{(key, value) -&gt;
                              when(value) {
                                  is String -&gt; {
                                      append(key, value)
                                  }
  
                                  is File -&gt; {
                                      append(key, value.inputStream().asInput())
                                  }
                              }
                          }
                      }
                  )
              }
              if(call.response.status.value == 500) {
                  return null
              }
              return call.response
  
  </code></pre>
  
  <p>The response status that is being returned is what is expected when no File is being sent. Any ideas on why this doesn't work?
  Are there any other ways to do this with Ktor?</p>