0

我试图使用API​​在Google云端硬盘中设置多个文件的权限。 我想批insert permission API使用Javascript中的Google Drive API批量插入权限API

到目前为止,这是我的尝试:

var httpBatch = gapi.client.newHttpBatch(); 

for(var fileIndex = 0; fileIndex < files.length; ++fileIndex) { 
    httpBatch.add(
    gapi.client.request({ 
     path: 'drive/v2/files/' + files[fileIndex].id + '/permissions', 
     method: 'POST', 
     params: { 
     value: '[email protected]', 
     type: 'user', 
     role: 'writer' 
     } 
    }) 
); 
} 

httpBatch.execute(callback); 

我也尝试使用API​​“gapi.client.drive.permissions.insert”但我不能找不到适当的配料方式。

我真的希望这是可能的。无论如何,我将不胜感激任何帮助。非常感谢。

回答

0

好的,我从Google员工那里得到了答案,非常感谢他们。

这里是如何要做到:

var httpBatch = gapi.client.newHttpBatch(); 

for(var fileIndex = 0; fileIndex < files.length; ++fileIndex) { 
    httpBatch.add(
    gapi.client.request({ 
     path: 'drive/v2/files/' + files[fileIndex].id + '/permissions', 
     method: 'POST', 
     headers: { 
     'Content-Type': 'application/json' 
     }, 
     body: JSON.stringify({ 
     value: '[email protected]', 
     type: 'user', 
     role: 'writer' 
     }) 
    }) 
); 
}