class Fastlane::Helper::GoogleDriveHelper

Public Class Methods

create_public_url(file) click to toggle source
# File lib/fastlane/plugin/google_drive/helper/google_drive_helper.rb, line 39
def self.create_public_url(file)
  raise "Not Google Drive file" unless file.kind_of?(::GoogleDrive::File)

  begin
    file.acl.push(type: "anyone", role: "reader")
    file.reload_metadata
    file.human_url
  rescue Exception => e
    UI.error(e.message)
    UI.user_error!("Create public link for '#{file.resource_id}' failed")
  end
end
create_subcollection(root_folder:, title:) click to toggle source
# File lib/fastlane/plugin/google_drive/helper/google_drive_helper.rb, line 52
def self.create_subcollection(root_folder:, title:)
  root_folder.create_subcollection(title)
rescue Exception => e
  UI.error(e.message)
  UI.user_error!("Create '#{title}' failed")
end
file_by_id(session: nil, fid: nil) click to toggle source
# File lib/fastlane/plugin/google_drive/helper/google_drive_helper.rb, line 19
def self.file_by_id(session: nil, fid: nil)
  file = session.file_by_id(fid)
  file
rescue Exception => e
  UI.error(e.message)
  UI.user_error!("File with id '#{fid}' not found in Google Drive")
end
setup(keyfile: nil, service_account: false) click to toggle source
# File lib/fastlane/plugin/google_drive/helper/google_drive_helper.rb, line 8
def self.setup(keyfile: nil, service_account: false)
  if service_account
    ::GoogleDrive::Session.from_service_account_key(keyfile)
  else
    ::GoogleDrive::Session.from_config(keyfile)
  end
rescue Exception => e
  UI.error(e.message)
  UI.user_error!('Invalid Google Drive credentials')
end
update_file(file: nil, file_name: nil) click to toggle source
# File lib/fastlane/plugin/google_drive/helper/google_drive_helper.rb, line 59
def self.update_file(file: nil, file_name: nil)
  raise "Not a Google Drive file" unless file.kind_of?(::GoogleDrive::File)

  begin
    file = file.update_from_file(file_name)
    file
  rescue Exception => e
    UI.error(e.message)
    UI.user_error!("Upload '#{file_name}' failed")
  end
end
upload_file(file: nil, file_name: nil, title: nil) click to toggle source
# File lib/fastlane/plugin/google_drive/helper/google_drive_helper.rb, line 27
def self.upload_file(file: nil, file_name: nil, title: nil)
  raise "Not Google Drive file" unless file.kind_of?(::GoogleDrive::File)

  begin
    file = file.upload_from_file(file_name, title, convert: false)
    file
  rescue Exception => e
    UI.error(e.message)
    UI.user_error!("Upload '#{file_name}' failed")
  end
end