use of org.pdown.core.boot.HttpDownBootstrap in project proxyee-down by monkeyWie.
the class AppUtil method fastDownload.
/**
* 使用pdown-core多连接下载http资源
*/
public static HttpDownBootstrap fastDownload(String url, File file, HttpDownCallback callback) throws IOException {
HttpDownBootstrap httpDownBootstrap = new URLHttpDownBootstrapBuilder(url, null, null).callback(callback).downConfig(new HttpDownConfigInfo().setFilePath(file.getParent()).setConnections(64)).response(new HttpResponseInfo().setFileName(file.getName())).proxyConfig(PDownConfigContent.getInstance().get().getProxyConfig()).build();
httpDownBootstrap.start();
return httpDownBootstrap;
}
use of org.pdown.core.boot.HttpDownBootstrap in project proxyee-down by monkeyWie.
the class NativeController method doUpdate.
@RequestMapping("doUpdate")
public FullHttpResponse doUpdate(Channel channel, FullHttpRequest request) throws Exception {
Map<String, Object> map = getJSONParams(request);
String url = (String) map.get("path");
String path = PathUtil.ROOT_PATH + File.separator + "proxyee-down-main.jar.tmp";
try {
File updateTmpJar = new File(path);
if (updateTmpJar.exists()) {
updateTmpJar.delete();
}
updateBootstrap = AppUtil.fastDownload(url, updateTmpJar, new HttpDownCallback() {
@Override
public void onDone(HttpDownBootstrap httpDownBootstrap) {
File updateBakJar = new File(updateTmpJar.getParent() + File.separator + "proxyee-down-main.jar.bak");
updateTmpJar.renameTo(updateBakJar);
}
@Override
public void onError(HttpDownBootstrap httpDownBootstrap) {
File file = new File(path);
if (file.exists()) {
file.delete();
}
httpDownBootstrap.close();
}
});
} catch (Exception e) {
throw e;
}
return new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
}
Aggregations