如何在Retrofit中使用JSON对象上传图像文件?

时间:2018-12-17 13:05:33

标签: android retrofit retrofit2 okhttp3

我需要将服务协议对象内的签名图像上传到API端点。这是API文档的图片

enter image description here

仅用于编辑现有服务协议,我具有以下改造界面:

@PUT("/v3/service_agreement_setups/{id}")
Single<Response<Agreement>> editAgreement(@Path("id") Integer id, @Body AgreementRequest agreementRequest);

AgreemnetRequest具有以下结构:

公共类AgreementRequest {

 @Expose @SerializedName("service_agreement_setup") private Agreement  agreement;

public AgreementRequest(Agreement agreement) {
this.agreement = agreement;
}

public Agreement getAgreement() {
return agreement;
}

public void setAgreement(Agreement agreement) {
this.agreement = agreement;
}
}

因此,正如您在“协议”类中看到的那样,我应该具有signature_image字段并上传图像文件。

我该怎么做?

0 个答案:

没有答案