Spaces:
Sleeping
Sleeping
Upload 17 files
Browse files- dashboardlogic.js +7 -4
dashboardlogic.js
CHANGED
|
@@ -480,10 +480,12 @@ async function handleUpload(input) {
|
|
| 480 |
const file = input.files[0]; // File/Blob is accepted by the client as `filepath`
|
| 481 |
try {
|
| 482 |
loading(true);
|
| 483 |
-
//
|
|
|
|
|
|
|
|
|
|
| 484 |
if (!client) {
|
| 485 |
-
|
| 486 |
-
client = await Client.connect("pockit-cloud/main", token ? { hf_token: token } : undefined);
|
| 487 |
}
|
| 488 |
const result = await client.predict("/upload_file_secure", {
|
| 489 |
user_id: currentUser,
|
|
@@ -491,6 +493,7 @@ async function handleUpload(input) {
|
|
| 491 |
filepath: file,
|
| 492 |
custom_name: file.name,
|
| 493 |
});
|
|
|
|
| 494 |
console.log('Uploaded:', file.name);
|
| 495 |
// Update storage
|
| 496 |
const [status, capacityUsed, usedTotal] = result.data;
|
|
@@ -503,7 +506,7 @@ async function handleUpload(input) {
|
|
| 503 |
showToast(file.name + ' uploaded');
|
| 504 |
input.value = '';
|
| 505 |
} catch (err) {
|
| 506 |
-
console.error('Upload error:', err);
|
| 507 |
showToast('Upload failed');
|
| 508 |
} finally {
|
| 509 |
loading(false);
|
|
|
|
| 480 |
const file = input.files[0]; // File/Blob is accepted by the client as `filepath`
|
| 481 |
try {
|
| 482 |
loading(true);
|
| 483 |
+
// Prepare token options robustly for different client versions
|
| 484 |
+
const token = getWriteToken() || getReadToken() || '';
|
| 485 |
+
const opts = token ? { hf_token: token, token } : {};
|
| 486 |
+
// Lazily connect the client (pass an options object even if empty to avoid version quirks)
|
| 487 |
if (!client) {
|
| 488 |
+
client = await Client.connect("pockit-cloud/main", opts);
|
|
|
|
| 489 |
}
|
| 490 |
const result = await client.predict("/upload_file_secure", {
|
| 491 |
user_id: currentUser,
|
|
|
|
| 493 |
filepath: file,
|
| 494 |
custom_name: file.name,
|
| 495 |
});
|
| 496 |
+
console.debug('Upload response:', result);
|
| 497 |
console.log('Uploaded:', file.name);
|
| 498 |
// Update storage
|
| 499 |
const [status, capacityUsed, usedTotal] = result.data;
|
|
|
|
| 506 |
showToast(file.name + ' uploaded');
|
| 507 |
input.value = '';
|
| 508 |
} catch (err) {
|
| 509 |
+
try { console.error('Upload error (detailed):', err?.message || err, err); } catch(_) {}
|
| 510 |
showToast('Upload failed');
|
| 511 |
} finally {
|
| 512 |
loading(false);
|