mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +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);
|
const file = event.target.files.item(0);
|
||||||
|
|
||||||
if (file) {
|
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);
|
uploadAttachment(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,8 @@
|
|||||||
"title_length_exceeded": "You have reached the maximum length",
|
"title_length_exceeded": "You have reached the maximum length",
|
||||||
"no_label_found": "No label found",
|
"no_label_found": "No label found",
|
||||||
"code_is_required": "Language code is required",
|
"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": {
|
"menu": {
|
||||||
"terms": "Terms of Use",
|
"terms": "Terms of Use",
|
||||||
|
@ -104,7 +104,8 @@
|
|||||||
"title_length_exceeded": "Vous avez atteint la longueur maximale",
|
"title_length_exceeded": "Vous avez atteint la longueur maximale",
|
||||||
"no_label_found": "Aucune étiquette trouvée",
|
"no_label_found": "Aucune étiquette trouvée",
|
||||||
"code_is_required": "Le code est requis",
|
"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": {
|
"menu": {
|
||||||
"terms": "Conditions d'utilisation",
|
"terms": "Conditions d'utilisation",
|
||||||
|
Loading…
Reference in New Issue
Block a user