/bfs.rb

Primary LanguageRubyApache License 2.0Apache-2.0

BFS

Build Status License

Abstraction for bucket storage.

Supported backends

Installation

Add this to your Gemfile, e.g. for S3 support:

gem 'bfs-s3'

Then execute:

$ bundle

Usage

require 'bfs/s3'

# connect to a bucket
bucket = BFS.resolve('s3://my-bucket?region=eu-west-2')

# create a file
bucket.create 'path/to/file.txt' do |f|
  f.write 'Hello World!'
end

# read that file
bucket.open 'path/to/file.txt' do |f|
  puts f.gets
end

# delete that file
bucket.rm 'path/to/file.txt'

# close the bucket again
bucket.close

Or, as a block:

require 'bfs/fs'

BFS.resolve('file:///absolute/path') do |bucket|
  bucket.ls('**').each do |file|
    puts file
  end
end