BFS
Abstraction for bucket storage.
Supported backends
- In-memory - for testing
-
Local file system - supports
file://
URLs -
(S)FTP - supports
ftp://
andsftp://
URLs -
Google Cloud Storage - supports
gs://
URLs -
Amazon S3 - supports
s3://
URLs -
SCP - supports
scp://
URLs
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