Java Code Examples for cn.hutool.http.HttpUtil#downloadFile()
The following examples show how to use
cn.hutool.http.HttpUtil#downloadFile() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AudioUtil.java From zfile with MIT License | 6 votes |
public static AudioInfoDTO getAudioInfo(String url) throws Exception { String query = new URL(URLUtil.decode(url)).getQuery(); if (query != null) { url = url.replace(query, URLUtil.encode(query)); } // 如果音乐文件大小超出 5M, 则不解析此音乐 if (im.zhaojun.zfile.util.HttpUtil.getRemoteFileSize(url) > (1024 * 1024 * ZFileConstant.AUDIO_MAX_FILE_SIZE_MB)) { return AudioInfoDTO.buildDefaultAudioInfoDTO(); } String fullFilePath = StringUtils.removeDuplicateSeparator(ZFileConstant.TMP_FILE_PATH + ZFileConstant.PATH_SEPARATOR + UUID.fastUUID()); File file = new File(fullFilePath); FileUtil.mkParentDirs(file); HttpUtil.downloadFile(url, file); AudioInfoDTO audioInfoDTO = parseAudioInfo(file); audioInfoDTO.setSrc(url); file.deleteOnExit(); return audioInfoDTO; }
Example 2
Source File: PluginManager.java From xJavaFxTool-spring with Apache License 2.0 | 6 votes |
public File downloadPlugin(PluginJarInfo pluginJarInfo) throws IOException { PluginJarInfo plugin = getPlugin(pluginJarInfo.getJarName()); if (plugin == null) { throw new IllegalStateException("没有找到插件 " + pluginJarInfo.getJarName()); } File file = new File("libs/", pluginJarInfo.getJarName() + "-" + pluginJarInfo.getVersion() + ".jar"); HttpUtil.downloadFile(pluginJarInfo.getDownloadUrl(), file); plugin.setIsDownload(true); plugin.setIsEnable(true); plugin.setLocalVersionNumber(plugin.getVersionNumber()); this.saveToFile(); return file; }
Example 3
Source File: YxArticleServiceImpl.java From yshopmall with Apache License 2.0 | 5 votes |
private WxMpMaterialUploadResult uploadPhotoToWx(WxMpService wxMpService, String picPath) throws WxErrorException { WxMpMaterial wxMpMaterial = new WxMpMaterial(); String filename = String.valueOf( (int)System.currentTimeMillis() ) + ".png"; String downloadPath = uploadDirStr + filename; long size = HttpUtil.downloadFile(picPath, cn.hutool.core.io.FileUtil.file(downloadPath)); picPath = downloadPath; File picFile = new File( picPath ); wxMpMaterial.setFile( picFile ); wxMpMaterial.setName( picFile.getName() ); log.info( "picFile name : {}", picFile.getName() ); WxMpMaterialUploadResult wxMpMaterialUploadResult = wxMpService.getMaterialService().materialFileUpload( WxConsts.MediaFileType.IMAGE, wxMpMaterial ); log.info( "wxMpMaterialUploadResult : {}", JSONUtil.toJsonStr( wxMpMaterialUploadResult ) ); return wxMpMaterialUploadResult; }
Example 4
Source File: UDIDController.java From signature with MIT License | 4 votes |
/** * create by: iizvv * description: 重签名 * create time: 2019-07-06 08:42 * @return String */ String resignature(Apple apple, String devId, String appLink) { String key = null; // ResourceUtils.getURL("classpath:").getPath() String classPath = "/root/"; long begin = System.currentTimeMillis(); File mobileprovision = ITSUtils.insertProfile(apple, devId, classPath); long end = System.currentTimeMillis(); long time = (end - begin)/1000; System.out.println("创建证书耗时: " + time + "秒"); String command = null; if (mobileprovision==null) { System.out.println("文件创建失败"); }else { System.out.println("文件创建成功"); String appUrl = Config.vpcAliMainHost + "/" + appLink; HttpUtil.downloadFile(appUrl, classPath); System.out.println("ipa下载完成: " + appUrl); File app = new File(classPath+appLink); String p12Url = Config.vpcAliMainHost + "/" + apple.getP12(); HttpUtil.downloadFile(p12Url, classPath); System.out.println("p12下载完成: " + p12Url); File p12 = new File(classPath+apple.getP12()); // 调用本地shell脚本并传递必须参数 command = "/root/ausign.sh " + app.getName() + " " + p12.getName() + " " + mobileprovision.getName(); System.out.println("调用shell进行签名: " + command); try { begin = System.currentTimeMillis(); boolean result = Shell.run(command); end = System.currentTimeMillis(); time = (end - begin)/1000; System.out.println("签名脚本执行耗时: " + time + "秒"); if (result) { key = uploadIPA(app); } } catch (IOException | InterruptedException e) { e.printStackTrace(); } finally { mobileprovision.delete(); app.delete(); p12.delete(); } } return key; }