I have captured image from camera and upload via upload API with retrofit.now i have got successfully response like:
{
"msg": "Image Upload Successful",
"status": 1,
"image": "115648975487_1551435779.png"
}
I have confused to save "image" name in shared preference and send this name as parameter in next API calling.
here is my code for upload image through Retrofit API:
public void imageUpload(final String imageEncoded){
file = new File(imageEncoded);
MultipartBody.Builder builder = new MultipartBody.Builder();
builder.setType(MultipartBody.FORM);
builder.addFormDataPart("image", file.getName(), RequestBody.create(MediaType.parse("multipart/form-data"), file));
ApiCall.callPostRetrofit(context, AppConstants.uploadImage, builder, new ApiCallBackListner() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonObject = new JSONObject(response);
String msg = jsonObject.getString("msg");
String status = jsonObject.getString("status");
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onError(String error) {
}
});
}