【问题标题】:Batch insert permissions API with Google Drive API in Javascript在 Javascript 中使用 Google Drive API 批量插入权限 API
【发布时间】:2013-07-18 02:57:13
【问题描述】:

我正在尝试使用他们的 API 为 Google Drive 中的多个文件设置权限。 我想批量处理insert permission 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: 'some_user@gmail.com',
        type: 'user',
        role: 'writer'
      }
    })
  );
}

httpBatch.execute(callback);

我也尝试使用 API“gapi.client.drive.permissions.insert”,但找不到正确执行批处理的方法。

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

【问题讨论】:

    标签: javascript batch-file permissions google-drive-api google-drive-realtime-api


    【解决方案1】:

    好的,我从 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: 'some_user@gmail.com',
            type: 'user',
            role: 'writer'
          })
        })
      );
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多