mirror of
https://github.com/hexastack/hexabot
synced 2025-01-22 18:45:57 +00:00
fix: add file type check
This commit is contained in:
parent
e0dd09d491
commit
1d72732fad
@ -99,6 +99,17 @@ const AttachmentUploader: FC<FileUploadProps> = ({
|
||||
const file = event.target.files.item(0);
|
||||
|
||||
if (file) {
|
||||
const acceptedTypes = accept.split(',');
|
||||
const isValidType = acceptedTypes.some((type) =>
|
||||
file.type === type || file.name.endsWith(type.replace('.*', ''))
|
||||
);
|
||||
|
||||
if (!isValidType) {
|
||||
toast.error(t("message.invalid_file_type"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
uploadAttachment(file);
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,8 @@
|
||||
"title_length_exceeded": "You have reached the maximum length",
|
||||
"no_label_found": "No label found",
|
||||
"code_is_required": "Language code is required",
|
||||
"text_is_required": "Text is required"
|
||||
"text_is_required": "Text is required",
|
||||
"invalid_file_type": "Invalid file type"
|
||||
},
|
||||
"menu": {
|
||||
"terms": "Terms of Use",
|
||||
|
@ -104,7 +104,8 @@
|
||||
"title_length_exceeded": "Vous avez atteint la longueur maximale",
|
||||
"no_label_found": "Aucune étiquette trouvée",
|
||||
"code_is_required": "Le code est requis",
|
||||
"text_is_required": "Texte requis"
|
||||
"text_is_required": "Texte requis",
|
||||
"invalid_file_type": "Type de fichier invalide"
|
||||
},
|
||||
"menu": {
|
||||
"terms": "Conditions d'utilisation",
|
||||
|
Loading…
Reference in New Issue
Block a user