FileHttpUpload extends FileHttpHandler { public String upload(String http, File file, Map<String, String> dataMap, FileAction<String> fileAction) { return upload(http, "", file, dataMap, fileAction); }  String upload(String http, File file, Map<String, String> dataMap, FileAction<String> fileAction); String upload(String http, String input, File file, Map<String, String> dataMap, FileAction<String> fileAction);  }
@Test public void testUpload() { Map<String, String> dataMap = new HashMap<String, String>(); dataMap.put("userId", "110"); FileAction<String> action = new FileAction<String>() { @Override public void progress(long speed, long size, long finishSize, double progress) { String speedText = "0MB/s"; if (speed < 1024) { speedText = speed + "B/s"; } else if (1024 <= speed && speed < (1024 * 1024)) { String s = OnlyNumberUtil.format(((double) speed / 1024d)); speedText = s + "KB/s"; } else { String s = OnlyNumberUtil.format(((double) speed / (double) (1024 * 1024))); speedText = s + "MB/s"; } StringBuilder sb = new StringBuilder(); sb.append("size:" + size); sb.append(" "); sb.append("finishSize:" + finishSize); sb.append(" "); sb.append("progress:" + progress); sb.append(" "); sb.append("speed:"); sb.append(speedText); sb.append(" "); System.out.println(sb); } @Override public void success(String t) { System.out.println("success:" + t); } @Override public void lost(String t) { } }; String http = "http: File file = new File("E:/Release/oss.zip"); fhu.upload(http, file, dataMap, action); }