1

I have a POST method send a JsonObject via Volley:

JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, url, postBody, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {                
             log("success");
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            log("" + error);
        }
    });
    request.setRetryPolicy(new DefaultRetryPolicy(10000, 0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    Volley.newRequestQueue(this).add(request);

With postBody:

JSONObject postBody = new JSONObject();
    try {
        postBody.put("name", "rome");
        //postBody.put("image", file?);
    } catch (JSONException e) {
        log("" + e);
    }

I want to send a image file with key "image" above. This file type is the same with file of form-data in PostMan (not url of file).

Is there anyway to do it? Thanks.

rome 웃
  • 1,821
  • 3
  • 15
  • 33

0 Answers0