mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-21 01:01:05 +08:00
Fix Upload Button (#3782)
* Fix upload btn * CHANGELOG --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
parent
72c9636370
commit
ad50eaa63d
@ -11,7 +11,8 @@
|
||||
- Fix bug where http token was not accessed over websocket connections by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3735](https://github.com/gradio-app/gradio/pull/3735)
|
||||
- Add ability to specify `rows`, `columns` and `object-fit` in `style()` for `gr.Gallery()` component by [@dawoodkhan82](https://github.com/dawoodkhan82) in [PR 3586](https://github.com/gradio-app/gradio/pull/3586)
|
||||
- Fix bug where recording an audio file through the microphone resulted in a corrupted file name by [@abidlabs](https://github.com/abidlabs) in [PR 3770](https://github.com/gradio-app/gradio/pull/3770)
|
||||
- Fix bug where iterators where not being reset for processes that terminated early by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3735](https://github.com/gradio-app/gradio/pull/3777)
|
||||
- Fix bug where iterators where not being reset for processes that terminated early by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3777](https://github.com/gradio-app/gradio/pull/3777)
|
||||
- Fix bug where the upload button was not properly handling the `file_count='multiple'` case by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3782](https://github.com/gradio-app/gradio/pull/3782)
|
||||
- Fix bug where use Via API button was giving error by [@Devang-C](https://github.com/Devang-C) in [PR 3783](https://github.com/gradio-app/gradio/pull/3783)
|
||||
|
||||
## Documentation Changes:
|
||||
|
@ -20,14 +20,27 @@
|
||||
async function handle_upload({ detail }: CustomEvent<FileData>) {
|
||||
value = detail;
|
||||
await tick();
|
||||
upload_files(root, [detail.blob!]).then(async (response) => {
|
||||
let files = (Array.isArray(detail) ? detail : [detail]).map(
|
||||
(file_data) => file_data.blob!
|
||||
);
|
||||
|
||||
upload_files(root, files).then(async (response) => {
|
||||
if (response.error) {
|
||||
detail.data = await blobToBase64(detail.blob!);
|
||||
(Array.isArray(detail) ? detail : [detail]).forEach(
|
||||
async (file_data, i) => {
|
||||
file_data.data = await blobToBase64(file_data.blob!);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
detail.orig_name = detail.name;
|
||||
detail.name = response.files![0];
|
||||
detail.is_file = true;
|
||||
(Array.isArray(detail) ? detail : [detail]).forEach((file_data, i) => {
|
||||
if (response.files) {
|
||||
file_data.orig_name = file_data.name;
|
||||
file_data.name = response.files[i];
|
||||
file_data.is_file = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dispatch("change", value);
|
||||
dispatch("upload", detail);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user