1.windows安装curl,配置环境变量
给Windows增加curl命令的环境变量,增加CURL_HOME环境变量,给PATH环境变量加上%CURL_HOME%;
CURL_HOME D:\curl
PATH %CURL_HOME%
这样就可以在命令窗口的任意目录下使用curl命令了。
2.springmvc rest接口
// 供ftp上传文件使用
@RequestMapping(value = "/ftpUpdate", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@ResponseBody
public HashMap<String, String> ftpUpdate(@RequestBody Map<String,Object> reqMap) {
HashMap<String, String> resMap = new HashMap<String, String>();
resMap.put("msg", "success");
//参数处理
String ename = (String) reqMap.get("appName");
boolean apkUpdate = (Boolean)reqMap.get("apkUpdate");
boolean ipaUpdate = (Boolean)reqMap.get("ipaUpdate");
String versionId = (String) reqMap.get("versionId");
if (ename == null) {
resMap.put("msg", "参数appName缺失异常");
return resMap;
}
if (reqMap.get("apkUpdate") == null) {
resMap.put("msg", "参数isApkUpdate缺失异常");
return resMap;
}
if (reqMap.get("ipaUpdate") == null) {
resMap.put("msg", "参数isIosUpdate缺失异常");
return resMap;
}
if (versionId == null) {
resMap.put("msg", "参数versionId缺失异常");
return resMap;
}
//更新信息维护
App oldApp=new App();
try {
oldApp = appService.getAppByEname(ename);
} catch (Exception e) {
resMap.put("msg", "没有这个app");
return resMap;
// TODO: handle exception
}
String rootPath = UploadFileController.class.getResource("/").getFile();
rootPath = rootPath.substring(1, rootPath.length() - 8);
String apkPath = rootPath + "file" + "/apk/" + ename + ".apk";
String ipaPath = rootPath + "file" + "/ipa/" + ename + ".ipa";
if (!versionId.equals("false")) {
oldApp.setVersionId(versionId);
}
if (apkUpdate) {
File file=new File(apkPath);
if (file.exists()) {
String apkSize = FileOpearte.getFileSize(file);
oldApp.setFileSize(apkSize);
appService.updateApp(oldApp);
FileOpearte.backupFile(oldApp.getId(),ename, oldApp.getVersionId(), oldApp.getUpdateDate(),"apk");
}
}
if (ipaUpdate) {
File file=new File(ipaPath);
if (file.exists()) {
oldApp = appService.getAppByEname(ename);
String ipaSize = FileOpearte.getFileSize(file);
oldApp.setIpaFileSize(ipaSize);
appService.updateApp(oldApp);
FileOpearte.backupFile(oldApp.getId(),ename,oldApp.getVersionId(), oldApp.getUpdateDate(),"ipa");
}
}
return resMap;
}
3.使用curl命令post json到后台
注意事项:
8256



被折叠的 条评论
为什么被折叠?



