package com.ks.app.utils; import java.util.Properties; /** * @author hxh * @title: ImageUtil * @description: 图片帮助类 * @date 2022/4/9 14:15 */ public class ImageUtil { private static String domain; private static String getVisitDomain() { if (domain == null) { Properties ps = org.yeshi.utils.PropertiesUtil .getProperties(ImageUtil.class.getClassLoader().getResourceAsStream("cos.properties")); domain = ps.getProperty("domain"); } return domain; } /** * @author hxh * @description 获取cos的图片访问路径 * @date 14:17 2022/4/9 * @param: key * @return java.lang.String **/ public static String getCOSImageUrl(String key) { return getVisitDomain() + key; } public static String getUrlKey(String imgUrl) { String url = imgUrl.replace("http://", "").replace("https://", ""); String key = url.substring(url.indexOf("/")); return key; } }