I am trying to convert a Word doc into a Google doc using the API via nodejs. The word docs are already in a folder and I just want to convert them into google docs. I am using v3.
The v3 docs say that in order to convert a file using copy you need to replace the convert parameter with the mimeType in the resource body.
I can't work out how to do that?
function listFiles(auth) {
const drive = google.drive({version: 'v3', auth});
drive.files.list({
q: "mimeType = 'application/msword'",
pageSize: 100,
fields: 'nextPageToken, files(id, name)',
}, (err, res) => {
if (err) return console.log('The API returned an error: ' + err);
const files = res.data.files;
if (files.length) {
console.log('Files:');
files.map((file) => {
console.log(`${file.name} (${file.id})`);
drive.files.copy({
fileId: file.id,
'name' : 'Updated File Name',
'mimeType' : 'application/vnd.google-apps.document'
})
});
} else {
console.log('No files found.');
}
});
}
Not sure that I am quite understanding how to reference the resource body. Would be grateful for a steer?