restful demo(有数据库,rest soap 共存)restful cxf maven jdbctemplate 类似七牛 图床 设计 demo
http://knight-black-bob.iteye.com/blog/2276961
android volley ,多文件 表单上传 http://knight-black-bob.iteye.com/blog/2311805
(volley multirequest 后台实现) restful 多文件 表单 上传
@POST @Consumes("multipart/form-data") @Path("/createFeed") public Response createFeed( List<Attachment>attachments,@Context HttpServletRequest request ) { long userFrom = 0; String userNickname = null,userIcon = null,location = null,content = null; List<FileKv> fileList = new ArrayList<FileKv>(); for (Attachment attach : attachments) { DataHandler dh = attach.getDataHandler(); System.out.println(attach.getContentType().toString()); // text/plain;charset=UTF-8 if (attach.getContentType().toString().contains("text/plain")) { try { System.out.println(dh.getName()); System.out.println(writeToString(dh.getInputStream())); if ("userFrom".equals(dh.getName())) { userFrom = Long.valueOf( writeToString(dh.getInputStream())); }else if("userNickname".equals(dh.getName())) { userNickname = writeToString(dh.getInputStream()) ; }else if("userIcon".equals(dh.getName())) { userIcon = writeToString(dh.getInputStream()) ; }else if("location".equals(dh.getName())) { location = writeToString(dh.getInputStream()) ; }else if("content".equals(dh.getName())) { content = writeToString(dh.getInputStream()) ; } } catch (Exception e) { e.printStackTrace(); } } else if(attach.getContentType().toString().contains("application/octet-stream")){ String path = request.getRealPath("/"); String picSaveName = DatetimeUtil.getYMDHMS_ms(new Date()); try { writeToFile(dh.getInputStream(), path +"img/feed/"+ picSaveName+".png"); fileList.add(new FileKv(dh.getName(),picSaveName)); } catch (IOException e) { e.printStackTrace(); } }else{ } } Feed feed = new Feed(); feed.setUserFrom(userFrom); feed.setUserNickname( userNickname ); feed.setUserIcon( userIcon ); feed.setLocation( location ); feed.setContent( content ); feed.setClicknum(0); feed.setInsertTime(new Date()); feed.setLastUpdateTime(new Date()); int feedId = feedDao.saveFeedReturnFeedId(feed); for (FileKv kv : fileList) { feedPicDao.saveFeedPic(new FeedPic(feedId, kv.fileName, Constants.BASEIP+"/RepositoryPic/WebService/rest/showPic/feed/"+kv.fileSaveName, new Date(), new Date() )); } QueryResultJson result = new QueryResultJson(400, "error", null); result = new QueryResultJson(); result.retcode = 200; result.retmsg = "success"; return Response.ok(result).build(); }
捐助开发者
在兴趣的驱动下,写一个免费
的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(右上角的爱心标志,支持支付宝和PayPal捐助),没钱捧个人场,谢谢各位。
谢谢您的赞助,我会做的更好!