Android 为什么我在尝试通过http上传时会使用代码删除一些信息?
我正在使用HttpClient上载我的文件。我试图上传19个文件 但只有3个文件上传成功 请告诉我为什么这不起作用,并给我一些建议或代码示例,如果可能的话 我的代码如下:Android 为什么我在尝试通过http上传时会使用代码删除一些信息?,android,http,upload,Android,Http,Upload,我正在使用HttpClient上载我的文件。我试图上传19个文件 但只有3个文件上传成功 请告诉我为什么这不起作用,并给我一些建议或代码示例,如果可能的话 我的代码如下: public void uploadLog() { new Thread(new Runnable() { @Override public void run() { HttpClient client = new DefaultHttpClient();
public void uploadLog() {
new Thread(new Runnable() {
@Override
public void run() {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(UPLOAD_LOG_URL);
InputStreamEntity reqEntity;
try {
File file=new File(Environment.getExternalStorageDirectory()
+ "/wlantest/report/");
Log.v("report/", file.getCanonicalPath());
File[] files=file.listFiles();
for(int i=0;i<files.length;i++)
{
reqEntity = new InputStreamEntity(new FileInputStream(
files[i].getCanonicalPath()), -1);
Log.v("test", "" + files[i].getCanonicalPath());
reqEntity.setContentType("application/x-zip-compressed");
reqEntity.setChunked(true);
post.setEntity(reqEntity);
HttpResponse response = client.execute(post);
Log.v("test", "" + response.getStatusLine().toString());
Log.v("test", "" + response.getStatusLine().getStatusCode());
if (response.getStatusLine().getStatusCode() == 200) {
MainActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "sucessed", Toast.LENGTH_SHORT).show();
File filetotal = new File(Environment.getExternalStorageDirectory() + "/wlantest/report/");
if (filetotal.listFiles().length != 0) {
report_total.setText("You have saved" + filetotal.listFiles().length
+ "reports" + "\n" + "click to upload");
}
else {
report_total.setText("You have no report\nafter saving will display");
progress.dismiss();
}
}
});
}
files[i].delete();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/*
* sendMesssage(MESSAGE_FINISH, 0); } else {
* sendMesssage(MESSAGE_FAILED, 0); } } catch (IOException e) {
* e.printStackTrace(); sendMesssage(MESSAGE_FAILED, 0); }
*/
}
}).start();
}
还有我的logcat
11-01 14:34:25.110:V/test874:HTTP/1.1200正常
11-01 14:34:25.110:V/test874:200
11-01 14:34:25.470:V/test874:/mnt/sdcard/wlantest/report/1351643286085.zip
11-01 14:34:25.470:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:连接仍已分配。
11-01 14:34:25.470:W/singleclientconnmanager 874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:25.540:V/test874:HTTP/1.1200正常
11-01 14:34:25.540:V/test874:200
11-01 14:34:25.550:V/test874:/mnt/sdcard/wlantest/report/1351644284660.zip
11-01 14:34:25.550:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:连接仍已分配。
11-01 14:34:25.550:W/SingleClientConnManager 874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:25.630:V/test874:HTTP/1.1200正常
11-01 14:34:25.630:V/test874:200
11-01 14:34:25.640:V/test874:/mnt/sdcard/wlantest/report/1351649375578.zip
11-01 14:34:25.640:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:连接仍已分配。
11-01 14:34:25.640:W/SingleClientConnManager 874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:25.790:V/test874:HTTP/1.1200正常
11-01 14:34:25.790:V/test874:200
11-01 14:34:25.790:V/test874:/mnt/sdcard/wlantest/report/135165055247.zip
11-01 14:34:25.790:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:连接仍已分配。
11-01 14:34:25.790:W/SingleClientConnManager 874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:26.700:V/test874:HTTP/1.1200正常
11-01 14:34:26.700:V/test874:200
11-01 14:34:28.620:V/test874:/mnt/sdcard/wlantest/report/1351652247364.zip
11-01 14:34:28.640:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:仍分配连接。
11-01 14:34:28.640:W/SingleClientConnManager 874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:28.780:V/test874:HTTP/1.1200正常
11-01 14:34:28.780:V/test874:200
11-01 14:34:28.780:V/test874:/mnt/sdcard/wlantest/report/1351652447759.zip
11-01 14:34:28.780:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:仍在分配连接。
11-01 14:34:28.780:W/SingleClientConnManager 874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:28.900:V/test874:HTTP/1.1200正常
11-01 14:34:28.900:V/test874:200
11-01 14:34:28.910:V/test874:/mnt/sdcard/wlantest/report/1351652790670.zip
11-01 14:34:28.920:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:仍分配连接。
11-01 14:34:28.920:W/SingleClientConnManager 874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:28.940:V/test874:HTTP/1.1200正常
11-01 14:34:28.940:V/test874:200
11-01 14:34:28.950:V/test874:/mnt/sdcard/wlantest/report/1351652906642.zip
11-01 14:34:28.950:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:连接仍已分配。
11-01 14:34:28.950:W/SingleClientConnManager 874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:29.070:V/test874:HTTP/1.1200正常
11-01 14:34:29.070:V/test874:200
11-01 14:34:29.080:V/test874:/mnt/sdcard/wlantest/report/1351653878048.zip
11-01 14:34:29.090:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:连接仍已分配。
11-01 14:34:29.090:W/SingleClientConnManager 874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:29.110:V/test874:HTTP/1.1200正常
11-01 14:34:29.110:V/test874:200
11-01 14:34:29.110:V/test874:/mnt/sdcard/wlantest/report/1351654209724.zip
11-01 14:34:29.110:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:连接仍已分配。
11-01 14:34:29.110:W/SingleClientConnManager 874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:29.200:V/test874:HTTP/1.1200正常
11-01 14:34:29.200:V/test874:200
11-01 14:34:29.210:V/test874:/mnt/sdcard/wlantest/report/1351661911878.zip
11-01 14:34:29.210:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:连接仍已分配。
11-01 14:34:29.210:W/SingleClientConnManager 874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:29.310:V/test874:HTTP/1.1200正常
11-01 14:34:29.310:V/test874:200
11-01 14:34:29.320:V/test874:/mnt/sdcard/wlantest/report/13516621
01340.zip
11-01 14:34:29.320:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:连接仍已分配。
11-01 14:34:29.320:W/SingleClientConnManager 874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:29.440:V/test874:HTTP/1.1200正常
11-01 14:34:29.440:V/test874:200
11-01 14:34:29.440:V/test874:/mnt/sdcard/wlantest/report/1351662348097.zip
11-01 14:34:29.450:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:仍然分配连接。
11-01 14:34:29.450:W/SingleClientConnManager 874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:29.550:V/test874:HTTP/1.1200正常
11-01 14:34:29.550:V/test874:200
11-01 14:34:29.550:V/test874:/mnt/sdcard/wlantest/report/1351662414224.zip
11-01 14:34:29.560:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:仍分配连接。
11-01 14:34:29.560:W/SingleClientConnManager874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:29.650:V/test874:HTTP/1.1200正常
11-01 14:34:29.650:V/test874:200
11-01 14:34:29.660:V/test874:/mnt/sdcard/wlantest/report/1351662757528.zip
11-01 14:34:29.660:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:连接仍已分配。
11-01 14:34:29.660:W/SingleClientConnManager874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:29.770:V/test874:HTTP/1.1200正常
11-01 14:34:29.770:V/test874:200
11-01 14:34:29.770:V/test874:/mnt/sdcard/wlantest/report/1351662878154.zip
11-01 14:34:29.780:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:仍分配连接。
11-01 14:34:29.780:W/SingleClientConnManager 874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:29.810:V/test874:HTTP/1.1200正常
11-01 14:34:29.810:V/test874:200
11-01 14:34:29.840:V/test874:/mnt/sdcard/wlantest/report/135166309338.zip
11-01 14:34:29.840:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:仍分配连接。
11-01 14:34:29.840:W/SingleClientConnManager874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:29.880:V/test874:HTTP/1.1200正常
11-01 14:34:29.880:V/test874:200
11-01 14:34:29.880:V/test874:/mnt/sdcard/wlantest/report/1351664456648.zip
11-01 14:34:29.880:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:仍分配连接。
11-01 14:34:29.880:W/SingleClientConnManager 874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:29.920:V/test874:HTTP/1.1200正常
11-01 14:34:29.920:V/test874:200
11-01 14:34:29.920:V/test874:/mnt/sdcard/wlantest/report/1351665696886.zip
11-01 14:34:29.930:W/SingleClientConnManager 874:SingleClientConnManager的使用无效:连接仍已分配。
11-01 14:34:29.930:W/SingleClientConnManager 874:请确保在分配另一个连接之前释放该连接。
11-01 14:34:29.960:V/test874:HTTP/1.1200正常
11-01 14:34:29.960:V/test874:200
11-01 14:34:30.010:D/memalloc874:ion:Unmapping buffer base:0x5d3d2000大小:196608
11-01 14:34:30.010:D/memalloc874:ion:取消映射缓冲区基址:0x5cf9a000大小:196608
11-01 14:34:30.010:D/memalloc874:ion:Unmapping buffer base:0x5cfca000 size:196608
因为我的服务器使用的是使用系统时间添加文件的方式,并且是每秒,比如16:43:44 16:43:45,但是我的上传速度太快了,我的服务器只能接收以连续时间命名的3个文件