浏览代码

fix: Update Google Drive file upload to use authorization headers

Taylor Wilsdon (aider) 4 月之前
父节点
当前提交
7dace30587
共有 2 个文件被更改,包括 7 次插入5 次删除
  1. 2 1
      src/lib/components/chat/Chat.svelte
  2. 5 4
      src/lib/utils/google-drive-picker.ts

+ 2 - 1
src/lib/components/chat/Chat.svelte

@@ -356,12 +356,13 @@
 			collection_name: '',
 			collection_name: '',
 			status: 'uploading',
 			status: 'uploading',
 			url: fileData.url,
 			url: fileData.url,
+			headers: fileData.headers,
 			error: ''
 			error: ''
 		};
 		};
 
 
 		try {
 		try {
 			files = [...files, fileItem];
 			files = [...files, fileItem];
-			const res = await processWeb(localStorage.token, '', fileData.url);
+			const res = await processWeb(localStorage.token, '', fileData.url, fileData.headers);
 
 
 			if (res) {
 			if (res) {
 				fileItem.status = 'uploaded';
 				fileItem.status = 'uploaded';

+ 5 - 4
src/lib/utils/google-drive-picker.ts

@@ -119,14 +119,15 @@ export const createPicker = () => {
                             url: fileUrl
                             url: fileUrl
                         });
                         });
                         
                         
-                        // Get the downloadUrl using the alt=media parameter
-                        // Construct download URL with access token
-                        const downloadUrl = `https://www.googleapis.com/drive/v3/files/${fileId}?alt=media&access_token=${oauthToken}`;
+                        // Construct download URL without embedding token
+                        const downloadUrl = `https://www.googleapis.com/drive/v3/files/${fileId}?alt=media`;
                         const result = {
                         const result = {
                             id: fileId,
                             id: fileId,
                             name: fileName,
                             name: fileName,
                             url: downloadUrl,
                             url: downloadUrl,
-                            token: oauthToken // Include token for future use
+                            headers: {
+                                'Authorization': `Bearer ${oauthToken}`
+                            }
                         };
                         };
                         console.log('Resolving picker with:', result);
                         console.log('Resolving picker with:', result);
                         resolve(result);
                         resolve(result);