Akram Bensalem
01/16/2022, 10:02 AMcurl --location -g --request POST '<https://svform.herokuapp.com/createUser/{userName}/{mobileNumber}>' \
--form 'profileImage=@"/Users/akram/Documents/14_07_2020-hbtu_kanpur_20509722.jpg"'
So I write a code like this:
@OptIn(InternalAPI::class)
suspend fun creatUser(
context : Context,
userName: String,
mobileNumber:String,
image: Uri,
) = client
.submitFormWithBinaryData<MemberEntity>(
url = "$POST_NEW_USER/$userName/$mobileNumber",
formData = formData {
append(
key = "profileImage",
value = getBinaryFile(context = context, contentUri = image)!!
)
},
){
onUpload { bytesSentTotal, contentLength ->
println("Sent $bytesSentTotal bytes from $contentLength")
}
}
I got an error of type :
Serializer for class 'BinaryItem' is not found.
When I add the ContentType, I got another error
Header(s) [Content-Type] are controlled by the engine and cannot be set explicitly
.....
Please any help ?Aleksei Tirman [JB]
01/16/2022, 10:10 AMformData = formData {
append("profileImage", File("/Users/akram/Documents/14_07_2020-hbtu_kanpur_20509722.jpg").readBytes(), Headers.build {
append(HttpHeaders.ContentType, "image/jpg")
append(HttpHeaders.ContentDisposition, "filename=14_07_2020-hbtu_kanpur_20509722.jpg")
})
}
Akram Bensalem
01/16/2022, 10:33 AMSerializer for class 'MultiPartFormDataContent' is not found.
Mark the class as @Serializable or provide the serializer explicitly.
Aleksei Tirman [JB]
01/16/2022, 12:06 PMAkram Bensalem
01/16/2022, 7:01 PM