@@ -2,21 +2,34 @@ package ru.soune.nocopy.entity.file;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
public enum FileType {
|
||||
PHOTO("photo"),
|
||||
IMAGE("image"),
|
||||
VIDEO("video"),
|
||||
AUDIO("audio"),
|
||||
DOCUMENT("document");
|
||||
PHOTO("photo", Arrays.asList("jpg", "jpeg", "png", "gif", "bmp", "webp")),
|
||||
IMAGE("image", Arrays.asList("jpg", "jpeg", "png", "gif", "bmp", "webp", "svg", "tiff")),
|
||||
VIDEO("video", Arrays.asList("mp4", "avi", "mov", "wmv", "flv", "mkv", "webm")),
|
||||
AUDIO("audio", Arrays.asList("mp3", "wav", "ogg", "aac", "flac", "m4a")),
|
||||
DOCUMENT("document", Arrays.asList("pdf", "doc", "docx", "txt", "rtf", "odt", "xls", "xlsx", "ppt", "pptx"));
|
||||
|
||||
private final String code;
|
||||
private final String displayName;
|
||||
private final List<String> allowedExtensions;
|
||||
|
||||
FileType(String code) {
|
||||
this.code = code;
|
||||
FileType(String displayName, List<String> allowedExtensions) {
|
||||
this.displayName = displayName;
|
||||
this.allowedExtensions = allowedExtensions;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public List<String> getAllowedExtensions() {
|
||||
return allowedExtensions;
|
||||
}
|
||||
|
||||
public boolean supportsExtension(String extension) {
|
||||
return allowedExtensions.contains(extension.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user