Project

bunbun

0.0
The project is in a healthy, maintained state
Ruby client for bunny.net
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

 Project Readme

bunbun

Gem Version

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.