.net C# 如何接收安卓(android)发送过来的数据流转换为图片
来源:互联网 发布:淘宝助理 二次验证 编辑:程序博客网 时间:2024/05/20 19:17
废话不多说直接上代码
android 端
AsyncHttpClient client = new AsyncHttpClient();client.setTimeout(300000);RequestParams params = new RequestParams();try {// // 压缩byte[] b = ImageCompressUtil.bitmapToByte(photoPath);InputStream mbitmap = new ByteArrayInputStream(b);params.put("picture", mbitmap);} catch (Exception e) {Log.e("slg", "图片不存在:" + photoPath);e.printStackTrace();}client.post(Constants.SEND_COMMUNITY_PICTURE_URL, params,new AsyncHttpResponseHandler() {@Overridepublic void onSuccess(String content) {// TODO Auto-generated method stubLog.d("tian", content);JSONObject jSONObject;try {jSONObject = new JSONObject(content);String s = jSONObject.getString("s");int sign = Integer.parseInt(s);if (sign == 0) {pic = jSONObject.getString("url");String picAddress = Constants.PIC_ADDRESS+ pic;ImageLoader.getInstance().displayImage(picAddress, community_send_show_img,ImageLoaderUtil.getPoints());Toast.makeText(context, "上传图片成功!",Toast.LENGTH_LONG).show();} else {Toast.makeText(context,jSONObject.getString("m"),Toast.LENGTH_LONG).show();}} catch (JSONException e) {// TODO Auto-generated catch blocke.printStackTrace();}}@Overridepublic void onStart() {// TODO Auto-generated method stubsuper.onStart();showProgressDialog(R.string.upload_img);}@Overridepublic void onFinish() {// TODO Auto-generated method stubsuper.onFinish();dismissProgressDialog();}});服务器端
public void uplpic(HttpContext context) { /***********上传文件由此处开始**********/ Random r = new Random(); string url = ""; url = r.Next(000000000, 999999999).ToString()+".jpg"; foreach (string f in HttpContext.Current.Request.Files.AllKeys) { HttpPostedFile file = HttpContext.Current.Request.Files[f]; file.SaveAs(System.Web.HttpContext.Current.Server.MapPath("~/upload/" + url)); } context.Response.Write("{\"s\":\"0\",\"url\":\"" + url + "\"}"); /************上传文件结束*******************/}
2 0
- .net C# 如何接收安卓(android)发送过来的数据流转换为图片
- .ashx接收APPCAN发送过来的图片数据流,保存为图片
- Flex接收51单片机发送过来的16进制数据转换为String
- 如何较好的处理对方发送过来的数据流
- servlet接收传过来的数据流
- 前端如何接收 websocket 发送过来的实时数据
- java 处理.net发送过来的数组,数组转换为java的基本类型,涉及到高低位转换
- android(SignalA)接收.net(SignalR)推送过来的消息
- asp.net 接收post过来的东西
- .net mvc3.0 中接收 json 数据,并转换为自定义的 C# 对象
- linux下如何控制RTS?为了控制RS485发送正常,但无法接收到端发送过来的数据
- linux下如何控制RTS?为了控制RS485发送正常,但无法接收到端发送过来的数据
- asp.net接收传入的数据流
- asp.net后台接收app发送的图片
- Android接收RabbitMQ推送过来的消息
- C#接收POST数据流
- <项目一>struts2+java 接收安卓客户端post过来的json字符串
- 使用ajax接收后台发送过来的json数据
- Java注解
- 用户名不能为空 Bad credentials.
- highcharts在导出时如何自定义图表的表头
- volley框架下,使用post方式请求服务器,传递参数和头
- HUST 1376 Random intersection
- .net C# 如何接收安卓(android)发送过来的数据流转换为图片
- php函数和语法结构
- 源码安装postgres,新建数据库用户遇到的问题
- 如何悄悄的访问谷歌
- iOS开发:Apply Pay商家接入指南-基础介绍
- 利用nginx来屏蔽指定的user_agent的访问
- getLocationInWindow 和 getLocationOnScreen的区别 以及computeVerticalScrollOffset
- 3.UIButton
- Using the SafetyNet API