I was never work with Jsoup before, and now I have a project, where guys were using JSoup lib, and I need to do some refactoring and make same work but with retrofit2...
I stuck with converting request that send image file. Here is original JSoup request:
Connection.Response result = Jsoup.connect(apiURL + "sendImg/")
.method(Connection.Method.POST)
.header("Token", XCSRFToken)
.data("source", currentImage.getMD5().concat(".jpg"),
new FileInputStream(bitmapURI.getPath()))
.execute();
here is what i try to do with retrofit:
@Multipart
@POST("sendImg/")
Call<CbSendImage> sendImage(@Header("Token") String token, @Part MultipartBody.Part file);
public void sendImage(File file) {
RequestBody requestFile =
RequestBody.create(MediaType.parse("multipart/form-data"), file);
MultipartBody.Part body =
MultipartBody.Part.createFormData("source",
currentImage.getMD5().concat(".jpg"), requestFile);
mSendImageCall = mServerApi.sendImage(getToken(), body);
mSendImageCall.enqueue(sendImageCallback);
}
but request still failed...
Any ideas how convert that request correct? Thanks!