0

I want to send image to sever with retrofit. But my image is in the custom class

Below is my 2 data class. I want to send LawRegRequest class to server. And in this class have lawyer field which is LawyerModel. And my image field (lawyer_card) is in this class. How I can send request?

class LawRegRequest(
    @SerializedName("email")
    var email : String,
    @SerializedName("first_name")
    var first_name : String,
    @SerializedName("last_name")
    var last_name : String,
    @SerializedName("phone")
    var phone : String,
    @SerializedName("password")
    var password : String,
    @SerializedName("password2")
    var password2 : String,
    @SerializedName("lawyer")
    var lawyer : LawyerModel) {
}
class LawyerModel(
    @SerializedName("father_name")
    var father_name : String,
    @SerializedName("gender")
    var gender : String,
    @SerializedName("birth_date")
    var birth_date : String,
    @SerializedName("university")
    var university : String,
    @SerializedName("service_languages")
    var service_languages : Array<Int>,
    @SerializedName("service_types")
    var service_types : Array<Int>,
    @SerializedName("voen")
    var voen : String,
    @SerializedName("law_practise")
    var law_practise : String,
    @SerializedName("lawyer_practise")
    var lawyer_practice : String,
    @SerializedName("lawyer_card")
    var lawyer_card : Any,
    @SerializedName("certificates")
    var certificates : Array<Any>) {
}

I looked lots of videos and forms but i can't find.

1 Answers1

0

In general, the binary data of an image is not stored in a class.

In general, you should upload an image first, and then use a reference to the image (such as imageId) as a field of the LawyerModel