admin
2022-05-12 fa705507ba574c857b1667553737d23b1b7ff495
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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;
    }
 
}