我们有一台Android,我们正在将备份数据库发送到Web服务器,以便在服务器上进行备份。
问题是服务器收到的文件没有扩展名,而且已损坏!
bouton_export.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//ContextWrapper contextWrapper = new ContextWrapper(getBaseContext());
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
File file = new File("data/data/fr.univtours.appelsuaps/databases/Appel.db");
FileBody fileBody = new FileBody(file);
HttpClient client = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://www.quentinlozach.com/get_database.php");
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
reqEntity.addPart("file", fileBody);
httpPost.setEntity(reqEntity);
HttpResponse response = null;
try {
response = client.execute(httpPost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if((response.getStatusLine().toString()).equals("HTTP/1.1 200 OK")){
// Successfully Uploaded
Log.i("uploaded", response.getStatusLine().toString());
}
else{
// Did not upload. Add your logic here. Maybe you want to retry.
Log.i(" not uploaded", response.getStatusLine().toString());
}
}
}).start();
}
知道它来自哪里?
感谢。