The documentation describes how to copy one file (https://developers.google.com/drive/api/v2/reference/files/copy), but nothing is said about the folder. This script, when copying a folder, gives an error 403:
window.gapi.client.drive.files
.create({
resource: {
name: this.currentFile.newTitle,
mimeType: 'application/vnd.google-apps.folder'
},
fields: 'id, name, mimeType, createdTime'
}).then(res => {
window.gapi.client.drive.files.list({
q: `'${this.currentFile.id}' in parents and trashed = false`,
fields: 'files(id, name, createdTime, mimeType)'
}).then(res => {
console.log(res)
res.result.files.forEach(file => {
window.gapi.client.drive.files
.copy({
fileId: file.id,
fields: 'id, name, mimeType, createdTime'
}).then(res => console.log(res))
})
})
})
I tried other solutions that I found on the Internet, but they also did not work. Could you please attach some sample code that works for you?
