下面是我的演示代码:
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put("sno", sno);
params.put("topic_id", topic_id);
return params;
}
@Override
protected Map<String, VolleyMultipartRequest.DataPart> getByteData() {
Map<String, DataPart> up_params = new HashMap<>();
String file_name = getFileName(imageUri);
File file = new File(selectfilePath);
up_params.put("attach_files", new DataPart(selectfilePath, file_name, "*/*"));
return up_params;
}
};
volleyMultipartRequest.setRetryPolicy(
new DefaultRetryPolicy(
0,
-1,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT
)
);
//adding the request to volley
// Volley.newRequestQueue(this).add(volleyMultipartRequest);
VolleySingleton.getInstance(getBaseContext()).addToRequestQueue(volleyMultipartRequest);
我成功上传了图片,但是当我允许上传所有类型的文件时,出现错误空指针异常,我尝试了很多事情。
如何在android中上传所有类型的文件?