Accessing shared drive with DriveApp

前端 未结 1 869
余生分开走
余生分开走 2021-01-06 15:45

I am trying to create a new file in a shared drive using google apps script so that other people using the shared drive can also access the file. Is there a method on DriveA

相关标签:
1条回答
  • 2021-01-06 16:15

    You need to use the Advanced Drive Service based on the Drive API

    The method Drive.Drives.insert allows you to specify the Drive Id.

    Keep in mind that for shared drives, you need to specify the additional parameter supportsAllDrives: true. Also, you need to enable the Advanced Drive Service before using.

    Sample:

    function myFunction() {  
      var optionalArgs={supportsAllDrives: true};
      var resource = {
        title: 'mySharedFile',
        mimeType: 'application/pdf',
        parents:[{
          "id": "ID OF THE SHARED DRIVE"
        }]
      }  
      Drive.Files.insert(resource, null, optionalArgs)
    }
    
    0 讨论(0)
提交回复
热议问题