How to upload a file in a folder GOOGLE DRIVE API
Solution 1:
In your situation, how about the following modification?
From:
const fileMetaData = {
'name': filename,
parents: [ID_FOLDER_DRIVE]
}
const media = {
mimeType: 'text/csv',
body: body
}
const res = await drive.files.create({
requestBody: {
resource: fileMetaData,
mimeType: 'application/vnd.google-apps.spreadsheet'
},
media: media
})
To:
const fileMetaData = {
name: filename,
parents: [ID_FOLDER_DRIVE],
mimeType: 'application/vnd.google-apps.spreadsheet'
}
const media = {
mimeType: 'text/csv',
body: body
}
const res = await drive.files.create({
requestBody: fileMetaData,
media: media
})
Reference:
- google-api-nodejs-client