虚拟机如何安装windows server 2008
2015-03-11 09:12
471 查看
使用http往服务端上传文件,要使用MultipartEntity,需要引入httpmime包,在附件中。
public static String postFile(String uploadFile, final String uploadType, String userId) throws ClientProtocolException, IOException, JSONException { HttpClient httpclient = new DefaultHttpClient(); //设置通信协议版本 httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); Log.i("chopin", uploadFile); HttpPost httppost = new HttpPost(Const.ImageUpload); File file = new File(uploadFile); MultipartEntity mpEntity = new MultipartEntity(); //文件传输 ContentBody cbFile = new FileBody(file); mpEntity.addPart("file", cbFile); mpEntity.addPart("userId",new StringBody(userId)); mpEntity.addPart("uploadType",new StringBody(uploadType)); httppost.setEntity(mpEntity); System.out.println("executing request " + httppost.getRequestLine()); HttpResponse response = httpclient.execute(httppost); HttpEntity resEntity = response.getEntity(); System.out.println(response.getStatusLine());//通信Ok String json=""; String path=""; if (resEntity != null) { json=EntityUtils.toString(resEntity,"utf-8"); Log.i("chopin", json); JSONObject p=null; try{ p=new JSONObject(json); path=(String) p.get("path"); }catch(Exception e){ e.printStackTrace(); } } if (resEntity != null) { resEntity.consumeContent(); } httpclient.getConnectionManager().shutdown(); return path; }
相关文章推荐
- 如何硬盘安装windows server 2008和windows7
- 如何在Windows Server 2008 R2上安装MOSS
- 如何解决在Windows Server 2008 R2 上安装证书服务重启后出现 CertificationAuthority 91错误事件
- 1,windows server 2008 如何安装Active Directory(向导安装)
- Windows Server 2008 R2虚拟机环境下安装Oracle RAC数据库(DBMS)
- Windows Server 2008 Core下如何安装Hyper-V
- 在虚拟机中安装Windows Server 2008企业版
- 如何在虚拟机VMware Player上安装Windows Server 2012
- DELL PowerEdge 2850 如何安装 Windows Server 2008 R2
- 如何在VMware Workstation11的Windows Server 2008 R2中安装XAMPP?
- 如何在Windows Server 2008上安装SharePoint2007
- 在虚拟机中安装Windows Server 2008 R2 图文介绍全过程
- Windows Server 2008 Core下如何安装Hyper-V
- Windows server 2008 安装虚拟机以及双网卡通过主机连接双局域网记录
- 如何在 Windows Server 2008 上安装并配置 Reporting Services 推荐
- 如何使用 U 盘开机安装 Windows 7 / Windows Server 2008 R2?(转)
- 如何在Windows Server 2008系统上安装Windows Phone模拟器
- 在虚拟机中安装Windows server 2008 图文详细过程
- Azure 虚拟机 Windows Server 2008 R2安装AzureBackupServiceAgent失败的解决方案
- Windows Server 2008 R2虚拟机下安装 Oracle RAC 详解(grid)