吉安感知网项目-后端
xiebin
2026-01-06 d207a86cdf1ab52ef8cb7cd83bad8fceab8038cf
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
package org.sxkj.common.utils;
 
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 
public class FileTypeUtils {
    static final String[] VIDEO_EXTENSIONS = {".mp4", ".avi", ".mov", ".wmv", ".flv", ".mkv", ".webm", ".mpeg", ".mpg", ".3gp"};
    static final String[] IMAGE_EXTENSIONS = {".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp", ".tiff", ".svg"};
 
    //是否视频文件
    public static boolean isVideoFile(String fileName) {
        if (StringUtils.isEmpty(fileName)) {
            return false;
        }
        fileName = fileName.toLowerCase();
        for (String ext : VIDEO_EXTENSIONS) {
            if (fileName.endsWith(ext)) {
                return true;
            }
        }
        return false;
    }
 
 
    public static boolean isImageFile(String fileName) {
        if (StringUtils.isEmpty(fileName)) {
            return false;
        }
        fileName = fileName.toLowerCase();
        for (String ext : IMAGE_EXTENSIONS) {
            if (fileName.endsWith(ext)) {
                return true;
            }
        }
        return false;
    }
}