Upload folder using huggingface_hub
Browse files- 6.3.1/upload/package.json +1 -1
- 6.3.1/upload/src/Upload.svelte +9 -11
6.3.1/upload/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/upload",
|
| 3 |
-
"version": "0.17.
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"main": "src/index.ts",
|
|
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/upload",
|
| 3 |
+
"version": "0.17.4",
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"main": "src/index.ts",
|
6.3.1/upload/src/Upload.svelte
CHANGED
|
@@ -97,20 +97,19 @@
|
|
| 97 |
_open_file_upload();
|
| 98 |
}
|
| 99 |
|
| 100 |
-
function handle_upload(
|
| 101 |
file_data: FileData[],
|
| 102 |
_upload_id?: string
|
| 103 |
): Promise<(FileData | null)[]> {
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
upload_id = _upload_id;
|
| 110 |
-
}
|
| 111 |
-
|
| 112 |
-
uploading = true;
|
| 113 |
|
|
|
|
|
|
|
|
|
|
| 114 |
try {
|
| 115 |
const _file_data = await upload(
|
| 116 |
file_data,
|
|
@@ -124,7 +123,6 @@
|
|
| 124 |
);
|
| 125 |
resolve(_file_data || []);
|
| 126 |
uploading = false;
|
| 127 |
-
return _file_data || [];
|
| 128 |
} catch (e) {
|
| 129 |
dispatch("error", (e as Error).message);
|
| 130 |
uploading = false;
|
|
|
|
| 97 |
_open_file_upload();
|
| 98 |
}
|
| 99 |
|
| 100 |
+
async function handle_upload(
|
| 101 |
file_data: FileData[],
|
| 102 |
_upload_id?: string
|
| 103 |
): Promise<(FileData | null)[]> {
|
| 104 |
+
if (!_upload_id) {
|
| 105 |
+
upload_id = Math.random().toString(36).substring(2, 15);
|
| 106 |
+
} else {
|
| 107 |
+
upload_id = _upload_id;
|
| 108 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
+
await tick();
|
| 111 |
+
uploading = true;
|
| 112 |
+
upload_promise = new Promise(async (resolve) => {
|
| 113 |
try {
|
| 114 |
const _file_data = await upload(
|
| 115 |
file_data,
|
|
|
|
| 123 |
);
|
| 124 |
resolve(_file_data || []);
|
| 125 |
uploading = false;
|
|
|
|
| 126 |
} catch (e) {
|
| 127 |
dispatch("error", (e as Error).message);
|
| 128 |
uploading = false;
|