I am using Apache httpclient and multi-page request to upload image file to server. I was able to upload the file using other clients, such as iphone and fiddler, to call the same api call on the server side. Not that lucky with Android ...
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(appController.getInstance().getURL().concat("/Api/ApiSales/UploadImages"));
post.addHeader("Authorization", appController.getInstance().getAuthTokenString());
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE)
File fileDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), Global.PHOTO_DIR);
for (File file : fileDir.listFiles()){
if (file.getName().equals("campusMarketLogo.png")){
Log.i("", "found campus logo file!");
FileInputStream fin = null;
try {
fin = new FileInputStream(file);
} catch (FileNotFoundException e) {
Log.e("", e.getLocalizedMessage());
}
byte[] fileContent = new byte[(int)file.length()];
try {
fin.read(fileContent);
} catch (IOException e) {
Log.e("", e.getLocalizedMessage());
}
ByteArrayBody bab = new ByteArrayBody(fileContent,"image/png",file.getName());
entity.addPart("File", bab);
}
}
post.setEntity(entity);
try {
client.execute(post, new uploadResponseHandler());
} catch (IOException e) {
Log.e("something is wrong", e.getLocalizedMessage());
}
When I read my log from Wireshark, I saw a TCP error:
[TCP retransmission] 62941 → 80 [ACK] Seq = 676 Ack = 1 Win = 14656 Len = 1448 TSval = 161633 TSecr = 516688742 [Build error, TCP protocol: New fragment overrides old data (retransmission?)]
Why such a TCP error?
source
share