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
|
// File upload functions
|
||||||
|
|
||||||
const uploadGoogleDriveFile = async (fileData) => {
|
const uploadGoogleDriveFile = async (fileData) => {
|
||||||
|
console.log('Uploading Google Drive file:', fileData);
|
||||||
const fileItem = {
|
const fileItem = {
|
||||||
type: 'doc',
|
type: 'doc',
|
||||||
name: fileData.name,
|
name: fileData.name,
|
||||||
collection_name: '',
|
collection_name: '',
|
||||||
status: 'uploading',
|
status: 'uploading',
|
||||||
url: fileData.url,
|
url: fileData.url,
|
||||||
headers: fileData.headers,
|
error: '',
|
||||||
error: ''
|
itemId: uuidv4()
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
files = [...files, fileItem];
|
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) {
|
if (res) {
|
||||||
|
console.log('File processed successfully:', res);
|
||||||
fileItem.status = 'uploaded';
|
fileItem.status = 'uploaded';
|
||||||
fileItem.collection_name = res.collection_name;
|
fileItem.collection_name = res.collection_name;
|
||||||
fileItem.file = {
|
fileItem.file = {
|
||||||
...res.file,
|
...res.file,
|
||||||
...fileItem.file
|
...fileItem.file
|
||||||
};
|
};
|
||||||
|
|
||||||
files = files;
|
files = files;
|
||||||
|
} else {
|
||||||
|
console.error('No response from processWeb');
|
||||||
|
throw new Error('Failed to process file');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
files = files.filter((f) => f.name !== fileData.name);
|
console.error('Error uploading file:', e);
|
||||||
toast.error(JSON.stringify(e));
|
files = files.filter((f) => f.itemId !== fileItem.itemId);
|
||||||
|
toast.error(e.toString());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user