Google Drive API uploading a file to team drive in Javascript

前端 未结 4 2244
醉话见心
醉话见心 2021-02-14 19:39

I have been having some issues with the google drive API and teamdrives. I can\'t for the life of me, figure out how to upload a file to team drive.

I\'m able to upload

4条回答
  •  忘掉有多难
    2021-02-14 20:13

    You have put the supportsTeamDrives:"true" in the wrong place.

    the docs https://developers.google.com/drive/api/v2/reference/files/insert specify that it needs to be a query parameter.

    So simply change your request query params to this:

    'params': {'uploadType': 'multipart', supportsTeamDrives: 'true' }

    So the whole request becomes:

    var request = gapi.client.request({
      'path': '/upload/drive/v2/files',
      'method': 'POST',
      'params': {'uploadType': 'multipart', 'supportsTeamDrives': 'true' },
      'headers': {
        'Content-Type': 'multipart/mixed; boundary="' + boundary + '"'
      },
      'body': multipartRequestBody
    });
    

提交回复
热议问题