我在 Android 的 base64 文件上传中遇到了异常。我在 Stackoverflow 中引用了这么多线程,但没有帖子解决我的问题。请尽快帮我解决这个问题。
我在这里粘贴我的 logcat 错误
02-07 19:18:11.536: E/AndroidRuntime(14445): FATAL EXCEPTION: AsyncTask #1
02-07 19:18:11.536: E/AndroidRuntime(14445): Process: com.ipage.fieldexecutive, PID: 14445
02-07 19:18:11.536: E/AndroidRuntime(14445): java.lang.RuntimeException: An error occured while executing doInBackground()
02-07 19:18:11.536: E/AndroidRuntime(14445): at android.os.AsyncTask$3.done(AsyncTask.java:300)
02-07 19:18:11.536: E/AndroidRuntime(14445): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
02-07 19:18:11.536: E/AndroidRuntime(14445): at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
02-07 19:18:11.536: E/AndroidRuntime(14445): at java.util.concurrent.FutureTask.run(FutureTask.java:242)
02-07 19:18:11.536: E/AndroidRuntime(14445): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
02-07 19:18:11.536: E/AndroidRuntime(14445): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
02-07 19:18:11.536: E/AndroidRuntime(14445): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
02-07 19:18:11.536: E/AndroidRuntime(14445): at java.lang.Thread.run(Thread.java:841)
02-07 19:18:11.536: E/AndroidRuntime(14445): Caused by: java.lang.IllegalArgumentException: Illegal character in path at index 76: /9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
02-07 19:18:11.536: E/AndroidRuntime(14445): AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEB
02-07 19:18:11.536: E/AndroidRuntime(14445): AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCABiAGIDASIA
02-07 19:18:11.536: E/AndroidRuntime(14445): AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA
02-07 19:18:11.536: E/AndroidRuntime(14445): AAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3
02-07 19:18:11.536: E/AndroidRuntime(14445): ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm
02-07 19:18:11.536: E/AndroidRuntime(14445): p6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA
02-07 19:18:11.536: E/AndroidRuntime(14445): AwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx
02-07 19:18:11.536: E/AndroidRuntime(14445): BhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElK
02-07 19:18:11.536: E/AndroidRuntime(14445): U1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3
02-07 19:18:11.536: E/AndroidRuntime(14445): uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD+AAAn
02-07 19:18:11.536: E/AndroidRuntime(14445): p/nkjPf0/UdzVyCAkE89QfyJB7dOO/TI5JBpbeDqSPTHHPU5z7dPpzyDWxbwd8enb3/l/nOaA/r8
02-07 19:18:11.536: E/AndroidRuntime(14445): /Py/PXR3bb2+ATjnj9Cee/68ZI6kYratbY89f4fX/b9/88+hp9vanHIOeOMf7WOuP07eoPNdLYad
02-07 19:18:11.536: E/AndroidRuntime(14445): vVndgiDaM/xFvnxtU4JHABYcA55+WtaNGriKns6UXOVrvtGKvec29IwileUpNJK13rdxOcKcZTnJ
02-07 19:18:11.536: E/AndroidRuntime(14445): RjHRttfLr36fmtRmn2LzMyqPurvckgAIpfceTycc7epGcc8D6V/Zh8e+BPh38VNH1nxd4Jk8c7rq
02-07 19:18:11.536: E/AndroidRuntime(14445): 3s9HhS8uLP8A4R/VZLhTa+J3aFSJ005wHNtJ+7c5DE4Jr50PnRTC1RW/eSoFRAWMh3FRjb8x3Hoo
02-07 19:18:11.536: E/AndroidRuntime(14445): 5J7HjH278LPh/ongnwdf+NdVt/tuoXmnTXzPPEY5bTTzE3m2KpnIOYt/mMBICRjGDn6jDZbhMPhX
02-07 19:18:11.536: E/AndroidRuntime(14445): Gdq2JrU5qdZLmhT55KMYYdTg0pJJOVacXNTbjS5VGbl5U8ZVlUvGypwnBqL+1HVuUndXvo1Bact+
02-07 19:18:11.536: E/AndroidRuntime(14445): ZtaH2R4U+If7NVl8R/E2m+DtXvpPiV8avFV34Q8ZeKV0fVxYeE7DxBcMmoa5cSPB9hmgsJmErgyh
02-07 19:18:11.536: E/AndroidRuntime(14445): GUfeC7mr85/jD4H1X9n341eJfBfja307xJp97LPqeheINM1exuodY0W5vJhZau66dNOlpNdxJ5j2
02-07 19:18:11.536: E/AndroidRuntime(14445): MrCeIMA6AgmqFr8eo/A3hz4iN4b8u7h8d2Wq+Hm0eSFYm0yHUlcHWLfUCj3BuIQcJEpU8KfMDYNf
02-07 19:18:11.536: E/AndroidRuntime(14445): N+j2Wr63Z2kcc1xqGo/bR+9vLmaV/s+2QKhlneRo4t3TJ2gkcHBJ5MoqY3LMzhVpxhN0ppVoVqVK
02-07 19:18:11.536: E/AndroidRuntime(14445): rSlRk5q06daEqc6bS1TV72sk4s6MZOlisLKM6koucE4TpznTnFptpQlCfOpO90r/AMrs7pn2/wCC
02-07 19:18:11.536: E/AndroidRuntime(14445): Jvhf4jjkitbF2u0jV3TbdbY9zbR+8ZAjEFcbQ2Rz3znsbb4d6Xd3cr22sfZLfgrC0LYT55M4Zjz0
02-07 19:18:11.536: E/AndroidRuntime(14445): XHfqckk1g/D7wrB4Z0G2iG1rq4jWe4kCrkPKql4wwJ3KjL8rZ5B5BPTc8SeJLHwxpNxqF/HPLCiO
02-07 19:18:11.536: E/AndroidRuntime(14445): SttDLLIQpz9yEFyemPXkcnLD9Kq8T5FUwrpZrwLwzi8Fh4yquGX4ark2Prziptc2PwVaM0qjjrHk
02-07 19:18:11.536: E/AndroidRuntime(14445): cbtOzbbXydHK8wVZ/U+Icyw9WvOFP2mJqQxmHpRlNpy9hXg17trtqSlbS7szmYDpT3tjaabfC8XU
02-07 19:18:11.536: E/AndroidRuntime(14445): b2502ymkRoBLeWfmfaI2EmPLCCMlXc7X52sSa7OPTJraVreVD5iBC4XDKAfMwdwOMH5cHJ4I64Br
02-07 19:18:11.536: E/AndroidRuntime(14445): 6B1v9n3wx4++G2leLtAsofAOs6FbrrVvpVlMdQj157q3iXN1czOjWDzLI10+EJEpMWOXJ+bNI1DV
02-07 19:18:11.536: E/AndroidRuntime(14445): ZJLHS9avYtJn1S6vbC0nhliuzOdMdg4kyV8rCIGySSSQOoIH5rwvieGONKmYYOGFxWU51icXToZN
02-07 19:18:11.536: E/AndroidRuntime(14445): h8BNVcpp1qidOll+KhjsRVxMJV66glj/AO0J0qdOpJzw6VLmn99xLkef8IrB1sXUw2My6WG9rXxF
02-07 19:18:11.536: E/AndroidRuntime(14445): VuGKnCEnKpiqaowjG1Kmm5YeWGpzlJRcZyVRcvTC0fHAPQdP+Be31/Xk9ipv+Eg0KLMT3Jd4z5bN
02-07 19:18:11.536: E/AndroidRuntime(14445): tX5mRpFZuHI+YrnjjGeTiivnppwnOEk1KEpQkrN+9GUovVLXWP4rV6siLUoqS2aTXo1K34R/Fdbn
02-07 19:18:11.536: E/AndroidRuntime(14445): 5L29vk9OmP5n2+vfHoRjI3rW29v7v/s3+f8ADHG74S8I654v8QaT4X8Oabc6rrOt6hZabp1lZ289
02-07 19:18:11.536: E/AndroidRuntime(14445): xNNdXlyttDmO3imkWMSOhlk2ERpudsha/TL9tb/gmj8Vv+CeXgX9m/X/AI+xw2njL9oLQtb1zQ/C
02-07 19:18:11.536: E/AndroidRuntime(14445): tleW+pWFpaaPfWltKbqeG2tbqzm2XsUiRXURZmLhTtXNbYWg8XiKOHjKNN1ZxhzzvyxTbTk7Jt2V
02-07 19:18:11.536: E/AndroidRuntime(14445): moxTnJtxinJWacrQcrN8qvZ2TfxLvZXsr30V1rpJnwD4Q+HfiLxXZ6jf6Zax/Y9MUm5nuZRboWWJ
02-07 19:18:11.536: E/AndroidRuntime(14445): pUSNpF2uZFQgBW3FiFAya5hrfU4rp1mtZ1ETbY4xDKY4l3PlY3CDcpPzbjk8kZ4bP2TLewaH4H8P
02-07 19:18:11.536: E/AndroidRuntime(14445): eF9K220t1bLceJbWM7Q2owXUhtGkBZi5EDrgnaQuPl+UE4unWkd/PHFLAkjSOkXzZ2ne5U7myAF6
02-07 19:18:11.536: E/AndroidRuntime(14445): ZPQDrzmv2jKuDMsllNKjSx8qOLqONTF1qlFSdeTa5KSgqilSoUZfw4qUnOSVaqnPkjH4jG57W9rW
02-07 19:18:11.536: E/AndroidRuntime(14445): UqMXSi7QjzNSjyuSbd/icnG70VleKlZtv558OxCXxJ4ZklU7l1zTEYMvJX7WCUZT2bH1wTkkjNfo
02-07 19:18:11.536: E/AndroidRuntime(14445): /wCOVj/4QvxcqIEjGhahtRRgKPIkHABHTk47ZPOS1eH6p8MtPgutONhZ2SXguIJkuIXBnS/SU+R5
02-07 19:18:11.536: E/AndroidRuntime(14445): ADt5nOwhsMQcDBOa+lNe+F3i23+FWpXmranbG41XSZ45n1S/tbVo
还有我的异步任务类
public class AddShopTask extends AsyncTask<String, Void, String> {
private ProgressDialog pDialog1;
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog1 = new ProgressDialog(AddShopActivity.this);
pDialog1.setMessage(getString(R.string.ip_updating_the_server));
pDialog1.setIndeterminate(false);
pDialog1.setCancelable(false);
pDialog1.show();
}
@Override
protected String doInBackground(String... params) {
String shopName = mShopNameEditText.getText().toString();
String shopDescription = mShopServiceDescription.getText().toString();
String landMark = mShopAddress.getText().toString();
String userType = "2";
String shopMobileNo = mShopMobileNumber.getText().toString();
String shopEmailId = mShopEmailId.getText().toString();
String shopPicture = encodeImageToB64Format();
String createdOn = String.valueOf(System.currentTimeMillis());
return HttpConnectionUtils.getAddShopResponse(shopName, shopPicture, landMark,
mShopCityName, shopMobileNo, shopEmailId, shopDescription, "paymentDetails",
createdOn, "78.37492398", "87.238829323", userType, shopPicture);
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
pDialog1.dismiss();
if (result != null && !result.trim().equals("")) {
try {
JSONObject loginResponseObj = new JSONObject(result);
String loginState = loginResponseObj.getString("result");
if (loginState.equals("success")) {
Toast.makeText(AddShopActivity.this, "Shop Added Successfully",
Toast.LENGTH_LONG).show();
finish();
} else {
iPreferenceUtils.clearAllPreferences(AddShopActivity.this);
Intent intent = new Intent(AddShopActivity.this, LoginActivity.class);
startActivity(intent);
finish();
}
} catch (Exception e) {
}
} else {
Crouton.makeText(AddShopActivity.this, R.string.err_check_your_connection,
Style.ALERT).show();
}
}
}
private String encodeImageToB64Format() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
profilePhoto.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] imageByte = baos.toByteArray();
String encodeShopImage = Base64.encodeToString(imageByte, Base64.NO_PADDING);
return encodeShopImage;
}