Ruby client for Yandex.Disk with backup gem support
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Yandex::Disk gem

Dead simple ruby wrapper for Yandex.Disk API

To get your access_token:

  1. Register your app at Yandex
    1. Be sure to check 'Yandex.Disk permits'
    2. Be sure to check 'Client for development' (it will set as Callback URI)
  2. Get access token
  3. Get your access token from redirect url (right from the browser, it will be one of parameters)


Add this line to your application's Gemfile:

gem 'yandex-disk'


# authorize via oauth access token...
disk = => 'YOUR_ACCESS_TOKEN')

# ...or use login password for authorization
disk = => 'me', :password => 'secret')

# to upload file to Yandex.Disk
disk.put('path/to/local/file', '/path/to/remote/file') # returns `true` if everything is ok

# to download file to Yandex.Disk
res = disk.get('/path/to/remote/file') # => res.body will contain file

# to make dir (only creates last part of path)
disk.mkdir('/path/to/remote/dir') # returns `true` if everything is ok

# to make full path

# remote file operations:

# copy file/dir
disk.copy('/path/to/remote/file/or/dir', '/path/to/new/remote/file/or/dir')
# move file/dir
disk.move('/path/to/remote/file/or/dir', '/path/to/new/remote/file/or/dir')
# delete file/dir
disk.delete('/path/to/remote/file/or/dir') # returns `true` if everything is ok

# property update operations:

# to make folder or file public
disk.make_public('/path/to/remote/dir/or/file') # returns hash with public url `=> { :public_url => "" }` if everything is ok

# to make folder or file private
disk.make_private('/path/to/remote/dir/or/file') # returns true if everything is ok

# to get quotas # returns hash like { :quota_available_bytes => 2488943615, :quota_used_bytes => 2488943615 }

# to get dir contents
disk.list('/') # returns array with hashes like [{:href=>"/",:resourcetype=>:collection,:getlastmodified=><DateTime>,:getcontentlength=>0,:displayname=>"disk",:creationdate=><DateTime>},{:href=>"/readme.pdf",:getlastmodified=><DateTime>,:getcontentlength=>455833,:displayname=>"readme.pdf",:creationdate=><DateTime>}]

Using it with backup gem

require 'yandex/disk/backup/storage', 'Description for my_backup') do
  split_into_chunks_of 50

  database PostgreSQL do |db|     = 'pg_db_name'
    db.username = 'username'
    db.password = 'password'

  compress_with Gzip

  store_with Yandex::Disk do |disk|
    disk.access_token = 'YOUR_ACCESS_TOKEN'
    disk.path         = '/backups/'
    disk.keep         = 5


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

To run tests setup env var with your access_token and run rake

export YANDEX_DISK_TOKEN=e5d4aaa4ec2246558b510f7fef25b7b1

Thanks for support and contribution