bunbun
Ruby client for the bunny.net API.
Installation
Using Bundler:
$ bundle add bunbun
Using RubyGems:
$ gem install bunbun
Usage
For accessing the bunny.net API:
require 'bunbun'
client = BunBun::Client.new(access_key: access_key)
client.storage_zone.list.each do |zone|
puts zone.values_at('Id', 'Name', 'FilesStored').join(' )
end
For accessing files on edge storage:
require 'bunbun'
file = 'image.jpg'
zone = 'zone-name'
host = 'storage.bunnycdn.com'
client = BunBun::Client.new(access_key: access_key, host: host)
client.download("/#{zone}/#{file}", file)
You can store your access key in a BUNNY_ACCESS_KEY environment variable,
and the storage host in a BUNNY_HOST environment variable.
CLI
The gem also includes a command line tool.
Store your access keys in your .netrc file, for example:
machine api.bunny.net
login user
password xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
machine storage.bunnycdn.com
login zone-name
password xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx-xxxx-xxxx
Specify the access key for the bunny.net API, and any additional keys for accessing edge storage. The login for the api.bunny.net entry can be anything, the login for each storage entry should be the name of the storage zone.
You can then use the bunny command line tool like this:
$ bunny storage zones
Run the tool without any arguments to see a list of available commands.