Skip to content

Instantly share code, notes, and snippets.

@joemsak
Created October 8, 2014 14:38
Show Gist options
  • Save joemsak/da63f495928155a801a6 to your computer and use it in GitHub Desktop.
Save joemsak/da63f495928155a801a6 to your computer and use it in GitHub Desktop.
require "rubygems"
require "google_drive"
# Logs in.
# You can also use OAuth. See document of
# GoogleDrive.login_with_oauth for details.
session = GoogleDrive.login("username@gmail.com", "mypassword")
# Gets list of remote files.
for file in session.files
p file.title
end
# Uploads a local file.
session.upload_from_file("/path/to/hello.txt", "hello.txt", :convert => false)
# Downloads to a local file.
file = session.file_by_title("hello.txt")
file.download_to_file("/path/to/hello.txt")
# Updates content of the remote file.
file.update_from_file("/path/to/hello.txt")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment