Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Shared Drives #360

Open
islemaster opened this issue Dec 18, 2019 · 2 comments
Open

Support Shared Drives #360

islemaster opened this issue Dec 18, 2019 · 2 comments

Comments

@islemaster
Copy link

Feature request: Add support for shared drives. If this is available now, I wasn't able to find documentation for it.

It looks like Team Drive support was added a couple of years ago (#259). Team Drive has since been renamed to "Shared Drives." The API documentation mentions a supportsAllDrives parameter that must be passed along with various requests, which might be the new version of the supports_team_drives parameter added at the time and still extant in v3.0.3 of the gem.

Thanks!

@stanhu
Copy link

stanhu commented Jul 15, 2020

With v3.0.5, I got shared drives to work. Currently it doesn't work because the drive ID is hard-coded to root here:

@root_collection ||= file_by_id('root')

I monkey patched this to the following:

module GoogleDrive
  # Monkey patches google-drive-ruby to support shared drives
  class Session
    def root_collection
      @root_collection ||= file_by_id(ENV['GOOGLE_DRIVE_ID'])
    end
  end
end

@aesyondu
Copy link

Hi, I don't think monkey patching is needed, it's not documented in the README, but it is possible to upload to shared GDrive folders ("collections" as per this library's source code):

GoogleDrive::Session
  .from_service_account_key(CONFIG)
  .collection_by_url("https://drive.google.com/drive/folders/gF1dvxQfFeRcQgFOdgid0aAcM1q9i6K15")
  .upload_from_file(file)

Make sure to share to the client_email (when using a service), as documented here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants