I am trying to upload a file to a shared drive, however; if I set my drive_id in the options parameters, it still used my default drive, which is "My Drive".
What am I doing wrong? (The drive_id is just an example)
google_file = Google::Apis::DriveV3::File.new(drive_id: "123456789", name: 'test.txt')
drive = Google::Apis::DriveV3::DriveService.new
source_file Tempfile.new("text.txt")
drive.create_file(google_file, upload_source: file)
I have also tried setting the parent_ids when I create a file and am getting an error as well. See below:
Google::Apis::DriveV3::File.new(drive_id: '123456789', name: 'test.txt', parents: ['123456789'])
results in:
Google::Apis::ClientError: notFound: File not found: 123456789.
Any help here will be greatly appreciated!
I believe your goal is as follows.
In this case, how about the following modification?
google_file = Google::Apis::DriveV3::File.new(name: 'test.txt', parents: ['###'])
drive = Google::Apis::DriveV3::DriveService.new
drive.create_file(google_file, upload_source: "text.txt", supports_team_drives: true)
###
of parents: ['###']
. If you want to upload the file to the root folder of the shared Drive, please set the drive ID to ###
of parents: ['###']
.drive
can be used for uploading the file to the shared Drive. Please be careful about this.