File uploading with ion

183 views Asked by At

I am trying to upload image file to my server with ion library.I am using following code

Ion.with(this, "upload_url")
                .setMultipartFile("imagefile", "image/jpeg", new File("file:///storage/emulated/0/Pictures/MyCameraApp/IMG_19700101_000000.jpg"))
                .asJsonObject()
                .setCallback(new FutureCallback<JsonObject>() {
                       @Override
                        public void onCompleted(Exception e, JsonObject result) {
                            Log.w("ERROR",""+e);
                            Log.w("RESULT",""+result);
                        }
                    });

But I am getting:

11-18 19:09:08.465: W/ERROR(1435): com.google.gson.JsonParseException: unable to parse json

What is wrong with this code ?

0

There are 0 answers