38 lines
959 B
TypeScript
38 lines
959 B
TypeScript
// TODO: 파일 타입 정책 협의 후 수정
|
|
const fileTypes = [
|
|
"image/apng",
|
|
"image/bmp",
|
|
"image/gif",
|
|
"image/jpeg",
|
|
"image/pjpeg",
|
|
"image/png",
|
|
// "image/svg+xml", // SVG 파일 차단
|
|
"image/tiff",
|
|
"image/webp",
|
|
"image/x-icon",
|
|
"video/mp4",
|
|
"video/mpeg",
|
|
"video/ogg",
|
|
"video/webm",
|
|
"video/3gpp",
|
|
"video/3gpp2",
|
|
"application/pdf",
|
|
"application/msword",
|
|
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
"application/vnd.ms-excel",
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
"application/vnd.ms-powerpoint",
|
|
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
"text/plain",
|
|
"text/csv",
|
|
];
|
|
|
|
export function validFileType(file: File) {
|
|
if (!fileTypes.includes(file.type)) throw new Error("Invalid file type");
|
|
return true;
|
|
}
|
|
|
|
export function combineFileName(file: File) {
|
|
return `${file.name}.${file.type.split("/")[1]}`;
|
|
}
|