I am trying to show a file from the Google Drive API inline so that the browser will display it. So far when I request the file it only downloads it. But when I add some code to make it show it in line I get the error “Failed to load PDF document”.
Here is my code:
const googleFile = new Request(`https://www.googleapis.com/drive/v3/files/${FileID}?alt=media`, {
method: "GET",
headers: {
"Authorization": `Bearer ${googletoken}`,
},
});
const googleFileResponse = new Response(fetch(googleFile), {
headers: {
'Content-Disposition': 'inline',
}
});
return googleFileResponse
Thanks for your help.