@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
@POST
@At({ "/file/?", "/file"})
@Ok("json")
@Filters({@By(type=CrossOriginFilter.class)})
public Object fileUpload(@Param("Filedata") TempFile tf, @Param("wjid") String wjid, HttpServletRequest req,
@Param("disksymbol")String disksymbol,AdaptorErrorContext err) throws Exception {
PropertiesUtil po = new PropertiesUtil("upload.properties");
String uploadtype = po.readProperty("uploadtype");
Result re = new Result();
if(disksymbol!=null&&!disksymbol.equals("")){
req.setAttribute("disksymbol", disksymbol);
}
if (err != null && err.getAdaptorErr() != null) {
return NutMap.NEW().addv("code", 1).addv("msg", "文件不合法");
} else if (tf == null) {
return Result.error("空文件");
} else {
if (uploadtype != null && !uploadtype.equals("")) {
switch (uploadtype) {
case "1":
re = localhostfile.executeUpload(tf, req);
break;
/*case "ftp":
ftpfile.executeUpload(tf, req);
break;*/
case "2":
mongofile.readyMongo();
re = mongofile.executeUpload(tf, req);
break;
case "3":
re = dbfile.executeUpload(tf, req);
default:
break;
}
return re;
} else {
return Result.error("配置文件错误");
}
}
}
@IocBean
public class MongoFile extends FileAbstract {
@Inject
MongoServiceImp mongoService;
public void readyMongo(){
mongoService.initMongo();
}
--------------------------------------------------------
public void initMongo(){
Ioc ioc = new NutIoc(new JsonLoader("config/ioc/mongodb.json"));
this.zMongo = ioc.get(ZMongo.class);
//this.zMongo = (ZMongo) Mvcs.ctx().get("zMongo");
this.zMoDB = ioc.get(ZMoDB.class, "zMoDB");
this.zMoCoUser = ioc.get(ZMoCo.class, "zMoCoUser");
this.zMoCoDir = ioc.get(ZMoCo.class, "zMoCoDir");
}