mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-24 10:54:04 +08:00
image upload fix (#7625)
* image upload fix * remove * add changeset * valid mimetype fix * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
parent
3d270d43f9
commit
8181695e70
6
.changeset/common-months-guess.md
Normal file
6
.changeset/common-months-guess.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"@gradio/upload": patch
|
||||
"gradio": patch
|
||||
---
|
||||
|
||||
feat:image upload fix
|
@ -28,7 +28,7 @@
|
||||
const dispatch = createEventDispatcher();
|
||||
const validFileTypes = ["image", "video", "audio", "text", "file"];
|
||||
const processFileType = (type: string): string => {
|
||||
if (type.startsWith(".")) {
|
||||
if (type.startsWith(".") || type.endsWith("/*")) {
|
||||
return type;
|
||||
}
|
||||
if (validFileTypes.includes(type)) {
|
||||
@ -116,7 +116,13 @@
|
||||
uploaded_file_extension: string,
|
||||
uploaded_file_type: string
|
||||
): boolean {
|
||||
if (!file_accept || file_accept === "*" || file_accept === "file/*") {
|
||||
if (
|
||||
!file_accept ||
|
||||
file_accept === "*" ||
|
||||
file_accept === "file/*" ||
|
||||
(Array.isArray(file_accept) &&
|
||||
file_accept.some((accept) => accept === "*" || accept === "file/*"))
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
let acceptArray: string[];
|
||||
@ -145,7 +151,7 @@
|
||||
const file_extension = "." + file.name.split(".").pop();
|
||||
if (
|
||||
file_extension &&
|
||||
is_valid_mimetype(filetype, file_extension, file.type)
|
||||
is_valid_mimetype(accept_file_types, file_extension, file.type)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user