mirror of
https://github.com/open-webui/open-webui
synced 2025-01-31 23:08:59 +00:00
fix: Update Google Drive Picker to show files and improve file upload process
This commit is contained in:
parent
b57f7251a5
commit
9faa5856f5
@ -364,16 +364,21 @@
|
|||||||
try {
|
try {
|
||||||
files = [...files, fileItem];
|
files = [...files, fileItem];
|
||||||
console.log('Processing web file with URL:', fileData.url);
|
console.log('Processing web file with URL:', fileData.url);
|
||||||
|
|
||||||
|
// Create headers with the Authorization token
|
||||||
|
const headers = {
|
||||||
|
'Authorization': fileData.headers.Authorization,
|
||||||
|
'Accept': 'application/json'
|
||||||
|
};
|
||||||
|
|
||||||
const res = await processWeb(
|
const res = await processWeb(
|
||||||
localStorage.token,
|
localStorage.token,
|
||||||
'',
|
'',
|
||||||
fileData.url,
|
fileData.url,
|
||||||
{
|
headers
|
||||||
'Authorization': fileData.headers.Authorization
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (res) {
|
if (res && res.collection_name) {
|
||||||
console.log('File processed successfully:', 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;
|
||||||
@ -382,14 +387,17 @@
|
|||||||
...fileItem.file
|
...fileItem.file
|
||||||
};
|
};
|
||||||
files = files;
|
files = files;
|
||||||
|
toast.success($i18n.t('File uploaded successfully'));
|
||||||
} else {
|
} else {
|
||||||
console.error('No response from processWeb');
|
console.error('Invalid response from processWeb:', res);
|
||||||
throw new Error('Failed to process file');
|
throw new Error('Failed to process file: Invalid server response');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error uploading file:', e);
|
console.error('Error uploading file:', e);
|
||||||
files = files.filter((f) => f.itemId !== fileItem.itemId);
|
files = files.filter((f) => f.itemId !== fileItem.itemId);
|
||||||
toast.error(e.toString());
|
toast.error($i18n.t('Error uploading file: {{error}}', {
|
||||||
|
error: e.message || 'Unknown error'
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -102,8 +102,9 @@ export const createPicker = () => {
|
|||||||
.enableFeature(google.picker.Feature.NAV_HIDDEN)
|
.enableFeature(google.picker.Feature.NAV_HIDDEN)
|
||||||
.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
|
.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
|
||||||
.addView(new google.picker.DocsView()
|
.addView(new google.picker.DocsView()
|
||||||
.setIncludeFolders(true)
|
.setIncludeFolders(false)
|
||||||
.setSelectFolderEnabled(true))
|
.setSelectFolderEnabled(false)
|
||||||
|
.setMimeTypes('application/pdf,text/plain,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.google-apps.document'))
|
||||||
.setOAuthToken(token)
|
.setOAuthToken(token)
|
||||||
.setDeveloperKey(API_KEY)
|
.setDeveloperKey(API_KEY)
|
||||||
// Remove app ID setting as it's not needed and can cause 404 errors
|
// Remove app ID setting as it's not needed and can cause 404 errors
|
||||||
|
Loading…
Reference in New Issue
Block a user