Beispiel #1
0
 @Test
 public void test_upload() throws Throwable {
   Request req = Request.create(getBaseURL() + "/upload/image", METHOD.POST);
   File f = File.createTempFile("nutz", "data");
   FileWriter fw = new FileWriter(f);
   fw.write("abc");
   fw.flush();
   fw.close();
   req.getParams().put("file", f);
   FilePostSender sender = new FilePostSender(req);
   Response resp = sender.send();
   assertEquals("image&3", resp.getContent());
 }
Beispiel #2
0
 public static void main(String[] args) {
   String path = Take.class.getResource("/").getPath();
   String proFile = path + "file.json";
   final List<String> urls = new ArrayList<String>();
   Files.readLine(
       Files.findFile(proFile),
       new Callback<String>() {
         @Override
         public void invoke(String str) {
           urls.add(str);
         }
       });
   for (String url : urls) {
     if (StringUtils.isBlank(url)) {
       continue;
     }
     Response req = Http.get(url);
     String savePath = path + "/temp/" + StringUtils.substringAfterLast(url, "/");
     savePath = StringUtils.substringBefore(savePath, "?");
     Files.write(savePath, req.getStream());
     System.out.println("save Path:" + savePath);
   }
 }