接收接口:
@At("/api/data/get/file")
@Ok("json")
@Override
public Responze getData(@Param("file") File file) {
if(file == null){
return new Responze(Codes.FAILURE, "获取业务数据失败,没有上传任何文件.");
}else{
}
}
上传:
Request req = Request.create("http://localhost/icov/api/data/get/file", Request.METHOD.POST);
File f = Files.findFile("file/cert01.jpg");
req.getParams().put("file", f);
FilePostSender sender = new FilePostSender(req);
Response resp = sender.send();
assertEquals("image&3", resp.getContent());
接收到的file参数一直是null.