I want to use the google apis to download a google slide as a power point presentation (ppt or pptx) to our node.js server. I have setup google drive api, and I have created a slide in my drive folder. I'm trying to use drive.files.export to download the slide, but since a slide isn't really a thing on windows or mac, I am trying to convert it to power point by setting the mimeType to application/vnd.ms-powerpoint:
const { drive } = await Google.getInstance();
const fileId = 'SomeLongTemplateId';
const fileName = 'test slide processing';
console.log('exporting ppt');
const ppt = await drive.files.export( // report.js:343
{ fileId, mimeType: 'application/vnd.ms-powerpoint' },
{ responseType: 'arraybuffer' }
);
return Buffer.from(ppt.data);
However, this throws and error and doesn't seem to work:
error: {
message: ArrayBuffer {
[Uint8Contents]: <7b 0a 20 22 65 72 72 6f 72 22 3a 20 7b 0a 20 20 22 65 72 72 6f 72 73 22 3a 20 5b 0a 20 20 20 7b 0a 20 20 20 20 22 64 6f 6d 61 69 6e 22 3a 20 22 67 6c 6f 62 61 6c 22 2c 0a 20 20 20 20 22 72 65 61 73 6f 6e 22 3a 20 22 62 61 64 52 65 71 75 65 73 74 22 2c 0a 20 20 20 20
22 6d 65 73 73 61 67 65 22 3a 20 ... 195 more bytes>,
byteLength: 295
},
stack: 'Error: [object ArrayBuffer]\n' +
' at Gaxios._request (C:\\Users\\rasmu\\Documents\\triggerz\\triggerz\\node_modules\\gaxios\\build\\src\\gaxios.js:129:23)\n' +
' at processTicksAndRejections (internal/process/task_queues.js:95:5)\n' +
' at async JWT.requestAsync (C:\\Users\\rasmu\\Documents\\triggerz\\triggerz\\node_modules\\google-auth-library\\build\\src\\auth\\oauth2client.js:345:18)\n' +
' at async processionSlide (C:\\Users\\rasmu\\Documents\\triggerz\\triggerz\\entity-access\\src\\act\\report.js:343:15)'
},
Unfortunately, it doesn't really say what the problem is, but it definitely doesn't work. I have also tried exporting as pptx using the mimeType application/vnd.openxmlformats-officedocument.presentationml.presentation but this gave a similar error.
I am used to export pdf's using this technique, and it works like a charm, the only difference is that I export a doc (google docs) and use the mimeType application/pdf
In the web UI of google drive, I can right-click on the slide and choose "download" this, downloads a pptx file that I can open with both MS power point and Libre office. - so it would surprise me a lot is the google node.js api library can't export in the same manner.
Any ideas how I can export a slide as a presentation that works on windows/mac ?
