Class: Flypbook::GoogleDrive
- Inherits:
-
Object
- Object
- Flypbook::GoogleDrive
- Defined in:
- lib/flypbook/google_drive.rb
Instance Method Summary collapse
-
#initialize(client_id, client_secret, refresh_token) ⇒ GoogleDrive
constructor
A new instance of GoogleDrive.
- #upload ⇒ Object
Constructor Details
#initialize(client_id, client_secret, refresh_token) ⇒ GoogleDrive
Returns a new instance of GoogleDrive.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/flypbook/google_drive.rb', line 5 def initialize(client_id, client_secret, refresh_token) credentials = ::Google::Auth::UserRefreshCredentials.new( client_id: client_id, client_secret: client_secret, scope: ::GoogleDrive::Session::DEFAULT_SCOPE, redirect_uri: 'urn:ietf:wg:oauth:2.0:oob', refresh_token: refresh_token ) @session = ::GoogleDrive::Session.new(credentials) end |
Instance Method Details
#upload ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/flypbook/google_drive.rb', line 16 def upload root_collection = @session.root_collection flypbook = root_collection.subcollection_by_title('Flypbook') || root_collection.create_subcollection('Flypbook') current_run_collection = flypbook.create_subcollection "journey_#{DateTime.now}" PhotoStore.screenshots.each do |screenshot| current_run_collection.add @session.upload_from_file(screenshot, screenshot, convert: false) end end |