HttpGet,HttpPost,HttpPut,HttpDelete
2012-05-19 13:33
309 查看
HttpGet-get and show data,the param will show in address url.(when the param is too long,use HttpPost is a wise choice.)
HttpPost-save and update data,the param will be hided.
HttpPut-add and create file/data on server
HttpDelete-delete file/data on server
Public Constructors
public HttpPut ()
public HttpPut (URI uri)
public HttpPut (String uri)
can be used to upload file,for example:
About this method,I just want to uplaod text file,so if you want to deal with the media.You have to study it by youself.
ing......
HttpPost-save and update data,the param will be hided.
HttpPut-add and create file/data on server
HttpDelete-delete file/data on server
HttpPut
Public Constructors
public HttpPut ()
public HttpPut (URI uri)
public HttpPut (String uri)
can be used to upload file,for example:
private void uploadFile(String fileName,String urlFolder){ Log.i(LOG_TAG, "uploadFile:"+urlFolder+fileName); try { HttpClient client = new DefaultHttpClient(); HttpPut put= new HttpPut(urlFolder+fileName); File record=new File(LogFile); if(record.exists()){ FileEntity fileEntity=new FileEntity(record,"UTF-8" ); put.setEntity(fileEntity); HttpResponse response = client.execute(put); Log.i(LOG_TAG, "response:"+response.getStatusLine()); if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK ||response.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED){ Log.i(LOG_TAG, "Upload OK!"); SharedPreferences settings = mContext.getSharedPreferences(Preferences.NAME_PREFERENCES, 0); SharedPreferences.Editor editor = settings.edit(); editor.putLong(LAST_UPLOADTIME, System.currentTimeMillis()); editor.commit(); } }else{ Log.i(LOG_TAG, "record file not exsit!"); } } catch (Exception e) { e.printStackTrace(); } }
About this method,I just want to uplaod text file,so if you want to deal with the media.You have to study it by youself.
ing......
相关文章推荐
- HTTP协议中POST、GET、HEAD、PUT等请求方法及相应值得含义
- 【Angular】angular-HttpClient 与服务器通讯 Get Post Put Delete Http 拦截器 请求讲解
- HTTP协议中POST、GET、HEAD、PUT等请求方法以及一些常见错误
- Android 网络请求方式之HttpClient,GET,POST,PUT请求使用方法
- Http 四种请求访问代码 HttpGet HttpPost HttpPut HttpDelete
- Java编程之HTTP的Post、Get、Put、Delete
- Http Get Post put delete
- HTTP协议中POST、GET、HEAD、PUT等请求方法以及一些常见错误
- Http 四种请求访问代码 HttpGet HttpPost HttpPut HttpDelete
- HTTP请求类型 get, post, put, delete汇总
- HTTP请求之GET,POST,DELETE,PUT
- ASIHTTPRequest实现对PUT,DELETE,POST,GET请求方式的处理
- PHP面试题:HTTP中POST、GET、PUT、DELETE方式的区别
- python实现的json数据以HTTP GET,POST,PUT,DELETE方式页面请求
- http协议中:GET/POST/PUT/DELETE/INPUT/TRACE/OPTIONS/HEAD方法
- ajax参数传递之[HttpGet]/[HttpPost]/[HttpPut]/[HttpDelete]请求
- 【Angular】angular-HttpClient 与服务器通讯 Get Post Put Delete Http 拦截器 请求讲解
- 关于HTTP协议中 GET, POST, PUT, DELETE等方法的详解
- HTTP协议中POST、GET、HEAD、PUT等请求方法以及一些常见错误
- python urllib2对http的get,put,post,delete