Google Drive API method files.get with alt: media parameter returning all special characters
See original GitHub issueI am trying to get a specific image file’s metadata so I can get the download url to input into a batch update request to create an image to input into a Google Slides presentation. I am using the files.get call which should return a lot of metadata. If I do the ‘Try it Out’ here it returns the correct data, however when I input that same fileId into my code, it only returns the name, id, kind and mimeType. I suspected this was because I need to add alt: media, but when I do that I get a return with all special characters.
Here is my code snippet:
authClient.refreshAccessToken(function(err, tokens) {
if (err) {
console.log(err);
return;
}
drive.files.get({
fileId: fileId,
auth: authClient,
alt: 'media'
}, function(err, res) {
if (err) {
return console.log(err);
}
else {
return console.log(res);
}
});
});
The return with alt: ‘media’ is a long list of special characters like this: A�c|��*����u�f����J
.
This is the return without alt: ‘media’:
{
kind: 'drive#file',
id: 'Photo ID',
name: 'Photo Name',
mimeType: 'image/jpeg'
}
EDIT: The below question has been partially solved. see below comment.
Also, I am wondering what the image url in the request body of the createImage object for the batchUpdate method should be. Here it just says to use the image url and when I’ve tried adding the self link, web content link, download url, embed link, etc. and I keep getting this error:
{
"error": {
"code": 400,
"message": "Invalid requests[0].createImage: There was a problem retrieving the specified image.",
"status": "INVALID_ARGUMENT"
}
}
Any advice would be greatly appreciated!
Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (6 by maintainers)
Top GitHub Comments
Yes, there is a tension here since the URL needs to be accessible for the Slides API backend to access it, which either means it’s publicly accessible for some period of time or the security token is captured in the URL and available in the presentation’s metadata.
Hey - I went another route when I was figuring this out, sorry I didn’t close this. When I wasn’t able to get the chart image address, I instead went the alternative route of using Google Sheets to create a new tab in a spreadsheet, add data and then create the chart to then send to the presentation.