feat: Improve Google Drive file download handling

This commit is contained in:
Taylor Wilsdon (aider) 2024-12-15 18:42:26 -05:00
parent eef18d4440
commit 64c8bbc16a
2 changed files with 6 additions and 2 deletions

View File

@ -501,12 +501,14 @@
try { try {
const fileData = await createPicker(); const fileData = await createPicker();
if (fileData) { if (fileData) {
// Pass the OAuth token along with the file data
dispatch('upload', { dispatch('upload', {
type: 'google-drive', type: 'google-drive',
data: { data: {
name: fileData.name, name: fileData.name,
url: fileData.url, url: fileData.url,
id: fileData.id id: fileData.id,
token: await getAuthToken() // Include OAuth token for download
} }
}); });
} }

View File

@ -111,10 +111,12 @@ export const createPicker = () => {
const fileName = doc[google.picker.Document.NAME]; const fileName = doc[google.picker.Document.NAME];
const fileUrl = doc[google.picker.Document.URL]; const fileUrl = doc[google.picker.Document.URL];
// Get the downloadUrl using the alt=media parameter
const downloadUrl = `https://www.googleapis.com/drive/v3/files/${fileId}?alt=media`;
resolve({ resolve({
id: fileId, id: fileId,
name: fileName, name: fileName,
url: fileUrl url: downloadUrl
}); });
} else if (data[google.picker.Response.ACTION] === google.picker.Action.CANCEL) { } else if (data[google.picker.Response.ACTION] === google.picker.Action.CANCEL) {
resolve(null); resolve(null);