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;
|
}
|
}
|