我不知道代码中的问题是什么。我想将csv文件上传到服务器。几天前它运行良好,但今天却显示错误,在这里我无法捕捉到该错误。
代码
String uploadServer = Constants.Base_URL + "csvupload/";
File file = new File(Environment.getExternalStorageDirectory()
.getAbsolutePath() + "/MyCsvFile7.csv");
final String uriSting = (file.getAbsolutePath());
Log.d(TAG, "file Path: " + uriSting);
SimpleMultiPartRequest smr = new SimpleMultiPartRequest(Request.Method.POST, uploadServer,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d(TAG, "responseMultipart" + response);
// Toast.makeText(getApplicationContext(), R.string.alert_comment_sukses, Toast.LENGTH_LONG).show();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(com.android.volley.error.VolleyError error) {
Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show();
Log.d(TAG, "responseMultipartError: " + error.getMessage());
}
});
smr.addStringParam("user", "122");
smr.addFile("image", uriSting);
Log.d(TAG, "smrParams" + smr);
requestQueue.add(smr);
错误
BasicNetwork.performRequest:(服务器URL)意外的响应代码403 W / System.err:com.android.volley.error.AuthFailureError W / System.err:位于com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:163) W / System.err:位于com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:118)
注意: 到目前为止,此api在邮递员中运行良好,但是现在我遇到了android studio问题