androidjsonandroid-async-httploopj

how to upload image file and json with Loopj AsyncHttpClient?


i want upload to Spring server @RequestBody

json and multipart-file(imgaefile) at ones.

how do i do?

Thanks for help.


Solution

  • I also had the same requirement I have used this code to Put the the image into server

        RequestParams params = new RequestParams();
        try {
            params.put("photo", FragmentPhotoCrop.croppedFile, "image/jpeg");  // croppedFile is a FIle 
            params.setUseJsonStreamer(false);
        } catch (FileNotFoundException e) {
        }
    
        asyncHttpClient.put(getActivity(), url, params, new AsyncHttpResponseHandler() { ..
    
           //enter code here
    
        }
    

    Hope it may help :)