Name: fog-backblaze
Owner: fog
Description: Integration library for gem fog and Backblaze B2 Cloud Storage
Created: 2017-09-30 16:45:52.0
Updated: 2018-05-19 05:29:43.0
Pushed: 2018-05-19 05:30:13.0
Homepage: null
Size: 37
Language: Ruby
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Integration library for gem fog and Backblaze B2 Cloud Storage
Add this line to your application's Gemfile:
'fog-backblaze'
Or install it with gem:
install fog-backblaze
ire "fog/backblaze"
ection = Fog::Storage.new(
ovider: 'backblaze',
_account_id: '123456',
_account_token: 'aaaaabbbbbccccddddeeeeeffffff111112222223333',
optional, used to make some operations faster
_bucket_name: 'app-test',
_bucket_id: '6ec42006ec42006ec42',
gger: Logger.new(STDOUT).tap {|l|
l.formatter = proc {|severity, datetime, progname, msg|
"#{severity.to_s[0]} - #{datetime.strftime("%T.%L")}: #{msg}\n"
}
ken_cache: 'file.txt'
See example for more details
Most of internal operations requires bucketId
field, to get right value, fog-backblaze will make API request.
Usually applications use only one bucket and it's id never change (it may change only if we delete bucket and create new one with same name).
We can eliminate this API request by setting b2_bucket_id
attribute.
How to get b2_bucket_id
:
nnection._get_bucket_id(bucket_name)
Each request requires authentication token, it comes from b2_authorize_account
response.
Let's say we want to upload a files, then it will make 4 requests inernally:
b2_authorize_account
- valid for 24 hoursb2_list_buckets
- to get bucket_id value can be optimized with :b2_bucket_id
field (should not change)b2_get_upload_url
- valid for 24 hoursResults of steps 1, 2, 3 can be re-used by saving in TokenCache. It acts as general cachin interface with few predefined implementations:
token_cache: :memory
(default)token_cache: 'file.txt'
token_cache: false
or token_cache: Fog::Backblaze::TokenCache::NullTokenCache.new