我应该在请求体中发送图像,我该如何制作?
RequestQueue requestQueue = Volley.newRequestQueue(getActivity());
String url = getString(R.string.url) + "auth/avatar?token="+ Utils.getToken(getActivity());
JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject jsonObject) {
Log.d("myLogs", jsonObject.toString());
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("avatar", encodedImage);
return params;
}
};
requestQueue.add(request);
我已阅读this article,但它对我没有帮助。