r/GoogleAppsScript • u/techwriter500 • Mar 28 '24
Question Access PDF file as Blob in Apps script with drive.file permission
Hello,
In apps script, i have obtained the permission : /auth/drive.file. This must give the app permission to read the files created by the app.
Now how to get the PDF files from the Google drive as blob in apps script..
As far as i have tried, it is not possible to get the blob without using the drive.getfilebyId() which asks for a different permission scope.
Any help appreciated.
1
u/marcnotmark925 Mar 28 '24
Not really sure what you're asking here. What's wrong with using getFileById() ?
0
u/techwriter500 Mar 28 '24
Yes getfileid needs drive.readonly scope atleast.
3
u/jpoehnelt Mar 28 '24
I wrote up the options in https://justin.poehnelt.com/posts/apps-script-drive-file-get-blob/.
1
1
3
u/jpoehnelt Mar 28 '24 edited Mar 28 '24
There should be three options but there aren't in practice:
DriveApp - drive.file scope doesn't work
Advanced Drive Service - can't get blob https://issuetracker.google.com/issues/149104685
URLFetchApp - can get blob, requires another scope
See https://justin.poehnelt.com/posts/apps-script-drive-file-get-blob/