mirror of
https://github.com/open-webui/open-webui
synced 2025-01-01 08:42:14 +00:00
feat: Implement file download with blob in Google Drive picker
This commit is contained in:
parent
1feaee8eca
commit
77490e3392
@ -136,19 +136,33 @@ export const createPicker = () => {
|
|||||||
console.log('Download URL constructed:', downloadUrl);
|
console.log('Download URL constructed:', downloadUrl);
|
||||||
|
|
||||||
console.log('Current token value:', token ? 'Token exists' : 'No token');
|
console.log('Current token value:', token ? 'Token exists' : 'No token');
|
||||||
|
// Create a Blob from the file download
|
||||||
|
console.log('Fetching file content...');
|
||||||
|
const response = await fetch(downloadUrl, {
|
||||||
|
headers: {
|
||||||
|
'Authorization': `Bearer ${token}`,
|
||||||
|
'Accept': '*/*'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Failed to download file: ${response.statusText}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const blob = await response.blob();
|
||||||
|
console.log('File downloaded, size:', blob.size);
|
||||||
|
|
||||||
const result = {
|
const result = {
|
||||||
id: fileId,
|
id: fileId,
|
||||||
name: fileName,
|
name: fileName,
|
||||||
url: downloadUrl,
|
url: downloadUrl,
|
||||||
|
blob: blob,
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Bearer ${token}`,
|
'Authorization': `Bearer ${token}`,
|
||||||
'Accept': 'application/json'
|
'Accept': '*/*'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
console.log('Created result object:', {
|
console.log('Created result object with blob');
|
||||||
...result,
|
|
||||||
headers: { ...result.headers, Authorization: `Bearer ${token}` }
|
|
||||||
});
|
|
||||||
resolve(result);
|
resolve(result);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error in picker callback:', error);
|
console.error('Error in picker callback:', error);
|
||||||
|
Loading…
Reference in New Issue
Block a user