private void shangchuan(){
//文件的路径
//File file=new File(path);
File file=new File(Environment.getExternalStorageDirectory()+"/dd.mp4");
//File file=new File(Environment.getExternalStorageDirectory()+"/"+System.currentTimeMillis()+".mp4");
HttpUtils httpUtils=new HttpUtils();
RequestParams params=new RequestParams();
SharedPreferences sp=getSharedPreferences("aa", Context.MODE_PRIVATE);
String userId=sp.getString("userid", "");
if (TextUtils.isEmpty(userId)) {
Toast.makeText(TakeVideoActivity.this, "请重新登录", Toast.LENGTH_SHORT).show();
return;
}
//给的接口
params.addBodyParameter("userid", userId);
params.addBodyParameter("file", file);
httpUtils.send(HttpMethod.POST, shangchuanUrl, params, new RequestCallBack<String>() {
@Override
public void onFailure(HttpException arg0, String arg1) {
Toast.makeText(TakeVideoActivity.this, "上传成功!!!", Toast.LENGTH_LONG).show();
}
@Override
public void onSuccess(ResponseInfo<String> arg0) {
System.out.println("上传结果:"+arg0.result);
Log.i("上传结果:", arg0.result);
}
@Override
public void onLoading(long total, long current, boolean isUploading) {
// TODO Auto-generated method stub
super.onLoading(total, current, isUploading);
System.out.println(""+current+"/"+total);
}
});
}