theguywhosucks commited on
Commit
299df5d
·
verified ·
1 Parent(s): da8cca5

Upload 17 files

Browse files
Files changed (1) hide show
  1. dashboardlogic.js +3 -15
dashboardlogic.js CHANGED
@@ -432,27 +432,15 @@ async function downloadFile(id) {
432
  });
433
  if (!resp.ok) throw new Error('Download-link HTTP ' + resp.status);
434
  const payload = await resp.json();
435
- const fileUrl = Array.isArray(payload.data) ? payload.data[0] : payload.data;
436
- if (typeof fileUrl === 'string' && (fileUrl.startsWith('http') || fileUrl.startsWith('https'))) {
437
- const response = await fetch(fileUrl);
438
- if (!response.ok) {
439
- console.error('Download fetch error:', {
440
- url: fileUrl,
441
- status: response.status,
442
- statusText: response.statusText
443
- });
444
- throw new Error('Network response was not ok');
445
- }
446
- const blob = await response.blob();
447
- const url = window.URL.createObjectURL(blob);
448
  const a = document.createElement('a');
449
- a.href = url;
450
  a.download = file.name;
451
  document.body.appendChild(a);
452
  a.click();
453
  setTimeout(() => {
454
  document.body.removeChild(a);
455
- window.URL.revokeObjectURL(url);
456
  }, 100);
457
  showToast('Download started: ' + file.name);
458
  } else {
 
432
  });
433
  if (!resp.ok) throw new Error('Download-link HTTP ' + resp.status);
434
  const payload = await resp.json();
435
+ const fileTarget = Array.isArray(payload.data) ? payload.data[0] : payload.data;
436
+ if (typeof fileTarget === 'string' && fileTarget) {
 
 
 
 
 
 
 
 
 
 
 
437
  const a = document.createElement('a');
438
+ a.href = '/api/download?file=' + encodeURIComponent(fileTarget);
439
  a.download = file.name;
440
  document.body.appendChild(a);
441
  a.click();
442
  setTimeout(() => {
443
  document.body.removeChild(a);
 
444
  }, 100);
445
  showToast('Download started: ' + file.name);
446
  } else {