mirror of
https://github.com/open-webui/open-webui
synced 2025-01-01 08:42:14 +00:00
feat: Improve Google Drive file upload handling with better logging and error management
This commit is contained in:
parent
b9499b4392
commit
b57f7251a5
@ -350,33 +350,46 @@
|
||||
// File upload functions
|
||||
|
||||
const uploadGoogleDriveFile = async (fileData) => {
|
||||
console.log('Uploading Google Drive file:', fileData);
|
||||
const fileItem = {
|
||||
type: 'doc',
|
||||
name: fileData.name,
|
||||
collection_name: '',
|
||||
status: 'uploading',
|
||||
url: fileData.url,
|
||||
headers: fileData.headers,
|
||||
error: ''
|
||||
error: '',
|
||||
itemId: uuidv4()
|
||||
};
|
||||
|
||||
try {
|
||||
files = [...files, fileItem];
|
||||
const res = await processWeb(localStorage.token, '', fileData.url, fileData.headers);
|
||||
console.log('Processing web file with URL:', fileData.url);
|
||||
const res = await processWeb(
|
||||
localStorage.token,
|
||||
'',
|
||||
fileData.url,
|
||||
{
|
||||
'Authorization': fileData.headers.Authorization
|
||||
}
|
||||
);
|
||||
|
||||
if (res) {
|
||||
console.log('File processed successfully:', res);
|
||||
fileItem.status = 'uploaded';
|
||||
fileItem.collection_name = res.collection_name;
|
||||
fileItem.file = {
|
||||
...res.file,
|
||||
...fileItem.file
|
||||
};
|
||||
|
||||
files = files;
|
||||
} else {
|
||||
console.error('No response from processWeb');
|
||||
throw new Error('Failed to process file');
|
||||
}
|
||||
} catch (e) {
|
||||
files = files.filter((f) => f.name !== fileData.name);
|
||||
toast.error(JSON.stringify(e));
|
||||
console.error('Error uploading file:', e);
|
||||
files = files.filter((f) => f.itemId !== fileItem.itemId);
|
||||
toast.error(e.toString());
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user