The problem of mixed upload of pictures with Retrofit parameters

The common parameters passed by

need to be encrypted. No matter how many parameters are encrypted, they become a string. The parameters submitted by Post are code= encrypted strings
something like this:

then the image does not need to be encrypted, just as the user edits his personal information and then modifies the profile picture and name. Then need to update to the server, the accompanying image does not need to be encrypted.

my approach is to convert the request to FormBody:

         //                      
         val commonParams = body.parts().single { part -> part.body().contentType() == MediaType.get("application/json; charset=utf-8") }
         //
         val fileParams = body.parts().first { part -> part.body().contentType() != MediaType.get("application/json; charset=utf-8") }
         //                  
         val encryptParams = buildEncryptParramsFromRequestBody(commonParams.body())

         val b = Buffer()
         fileParams.body().writeTo(b)
         //FormBody
         val builder = FormBody.Builder().addEncoded("code", encryptParams).addEncoded("avator", b.readUtf8()).build()

         request = Request.Builder().url(request.url()).post(builder).build()

this interface returns success, but in fact, the server does not update the image. I would like to ask you how to operate this piece, thank you very much!

Menu