mirror of
https://github.com/open-webui/open-webui
synced 2025-01-01 08:42:14 +00:00
feat: Add detailed logging for file download process to diagnose download issues
This commit is contained in:
parent
42af98ae28
commit
a865420cb1
@ -391,18 +391,51 @@
|
|||||||
throw new Error(`Failed to fetch file: ${fileResponse.statusText}`);
|
throw new Error(`Failed to fetch file: ${fileResponse.statusText}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('Response received, converting to blob...');
|
||||||
const fileBlob = await fileResponse.blob();
|
const fileBlob = await fileResponse.blob();
|
||||||
|
console.log('Blob created:', {
|
||||||
|
size: fileBlob.size,
|
||||||
|
type: fileBlob.type
|
||||||
|
});
|
||||||
|
|
||||||
const file = new File([fileBlob], fileData.name, { type: fileBlob.type });
|
const file = new File([fileBlob], fileData.name, { type: fileBlob.type });
|
||||||
|
console.log('File object created:', {
|
||||||
|
name: file.name,
|
||||||
|
size: file.size,
|
||||||
|
type: file.type
|
||||||
|
});
|
||||||
|
|
||||||
// Create a download link for debugging
|
// Create and trigger download
|
||||||
const downloadUrl = URL.createObjectURL(fileBlob);
|
try {
|
||||||
const downloadLink = document.createElement('a');
|
console.log('Creating download URL...');
|
||||||
downloadLink.href = downloadUrl;
|
const downloadUrl = URL.createObjectURL(fileBlob);
|
||||||
downloadLink.download = fileData.name;
|
console.log('Download URL created:', downloadUrl);
|
||||||
document.body.appendChild(downloadLink);
|
|
||||||
downloadLink.click();
|
const downloadLink = document.createElement('a');
|
||||||
document.body.removeChild(downloadLink);
|
downloadLink.href = downloadUrl;
|
||||||
URL.revokeObjectURL(downloadUrl);
|
downloadLink.download = fileData.name;
|
||||||
|
console.log('Download link created with:', {
|
||||||
|
href: downloadLink.href,
|
||||||
|
download: downloadLink.download
|
||||||
|
});
|
||||||
|
|
||||||
|
// Force the download to happen in the foreground
|
||||||
|
downloadLink.style.display = 'none';
|
||||||
|
document.body.appendChild(downloadLink);
|
||||||
|
console.log('Link added to document');
|
||||||
|
|
||||||
|
downloadLink.click();
|
||||||
|
console.log('Download triggered');
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
setTimeout(() => {
|
||||||
|
document.body.removeChild(downloadLink);
|
||||||
|
URL.revokeObjectURL(downloadUrl);
|
||||||
|
console.log('Cleanup completed');
|
||||||
|
}, 100);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Download failed:', error);
|
||||||
|
}
|
||||||
|
|
||||||
console.log('File fetched successfully, uploading to server...');
|
console.log('File fetched successfully, uploading to server...');
|
||||||
const uploadedFile = await uploadFile(localStorage.token, file);
|
const uploadedFile = await uploadFile(localStorage.token, file);
|
||||||
|
Loading…
Reference in New Issue
Block a user