fog-backblaze 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +4 -3
- data/CHANGELOG.md +7 -0
- data/Gemfile +2 -1
- data/lib/fog/backblaze.rb +2 -5
- data/lib/fog/backblaze/json_response.rb +3 -1
- data/lib/fog/{storage/backblaze.rb → backblaze/storage.rb} +4 -4
- data/lib/fog/{storage/backblaze → backblaze/storage}/mock.rb +1 -1
- data/lib/fog/{storage/backblaze → backblaze/storage}/models/directories.rb +2 -2
- data/lib/fog/{storage/backblaze → backblaze/storage}/models/directory.rb +2 -2
- data/lib/fog/{storage/backblaze → backblaze/storage}/models/file.rb +2 -2
- data/lib/fog/{storage/backblaze → backblaze/storage}/models/files.rb +9 -9
- data/lib/fog/{storage/backblaze → backblaze/storage}/real.rb +4 -4
- data/lib/fog/backblaze/token_cache.rb +3 -1
- data/lib/fog/backblaze/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a78389a8f10d5fbb3db2898d5b8e5753a83efff4a0597298ab6d025e84890bcd
|
4
|
+
data.tar.gz: 6b810bccc7ab401b8ef658f18a4e2217f436ed2f0228e3efa4215bf4039c74b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73d97139b00707f5445c235201310377132dc7243732679e325b8a0b8e92be938fad44eedb0a9db1b99c147b390aaea258158b90c7453249ac2ba4177c421c1b
|
7
|
+
data.tar.gz: f84b8deeb28d28810cef58344fad698765fd2280e48786b09549995e1b7e6d2eb0c5cb940ed30514a3b0c3c54f2fb1a39bddfa7aad4d8f7d8475406d383c8955
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
0.3.0 2019-06-27
|
2
|
+
==========================================================
|
3
|
+
|
4
|
+
- Fixes issues with not saving a file content_type as well as bad calls for the fog methods (Thanks @dan)
|
5
|
+
- method name typo: josn_response?->json_response? (Thanks @MatthiasWinkelmann)
|
6
|
+
- Change Fog::Storage::Backblaze -> Fog::Backblaze::Storage
|
7
|
+
|
1
8
|
0.2.0 2018-08-16
|
2
9
|
==========================================================
|
3
10
|
|
data/Gemfile
CHANGED
data/lib/fog/backblaze.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
require 'fog/core'
|
2
|
-
require 'json'
|
3
2
|
|
4
3
|
module Fog
|
5
4
|
module Backblaze
|
6
5
|
autoload :JSONResponse, File.expand_path("../backblaze/json_response", __FILE__)
|
7
6
|
autoload :TokenCache, File.expand_path("../backblaze/token_cache", __FILE__)
|
8
7
|
|
8
|
+
autoload :Storage, File.expand_path("../backblaze/storage", __FILE__)
|
9
|
+
|
9
10
|
extend Fog::Provider
|
10
11
|
service(:storage, "Storage")
|
11
12
|
end
|
12
|
-
|
13
|
-
module Storage
|
14
|
-
autoload :Backblaze, File.expand_path("../storage/backblaze", __FILE__)
|
15
|
-
end
|
16
13
|
end
|
@@ -2,17 +2,17 @@ require 'json'
|
|
2
2
|
require 'digest'
|
3
3
|
require 'cgi'
|
4
4
|
|
5
|
-
class Fog::Storage
|
5
|
+
class Fog::Backblaze::Storage < Fog::Service
|
6
6
|
#requires
|
7
7
|
recognizes :b2_account_id, :b2_account_token, :b2_key_id, :b2_key_token,
|
8
8
|
:b2_bucket_name, :b2_bucket_id, :token_cache, :logger
|
9
9
|
|
10
|
-
model_path 'fog/storage/
|
10
|
+
model_path 'fog/backblaze/storage/models'
|
11
11
|
model :directory
|
12
12
|
collection :directories
|
13
13
|
model :file
|
14
14
|
collection :files
|
15
15
|
|
16
|
-
autoload :Mock, File.expand_path("../
|
17
|
-
autoload :Real, File.expand_path("../
|
16
|
+
autoload :Mock, File.expand_path("../storage/mock", __FILE__)
|
17
|
+
autoload :Real, File.expand_path("../storage/real", __FILE__)
|
18
18
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Fog::Storage::
|
1
|
+
class Fog::Backblaze::Storage::Directory < Fog::Model
|
2
2
|
identity :key, aliases: %w(bucketName)
|
3
3
|
|
4
4
|
attribute :bucket_id#, aliases: 'bucketId'
|
@@ -56,7 +56,7 @@ class Fog::Storage::Backblaze::Directory < Fog::Model
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def files
|
59
|
-
@files ||= Fog::Storage::
|
59
|
+
@files ||= Fog::Backblaze::Storage::Files.new(directory: self, service: service)
|
60
60
|
end
|
61
61
|
|
62
62
|
def public?
|
@@ -1,8 +1,8 @@
|
|
1
|
-
class Fog::Storage::
|
1
|
+
class Fog::Backblaze::Storage::File < Fog::Model
|
2
2
|
|
3
3
|
identity :file_name, aliases: %w{fileName key name}
|
4
4
|
|
5
|
-
attribute :content_length, aliases: 'contentLength'
|
5
|
+
attribute :content_length, aliases: 'contentLength', :type => :integer
|
6
6
|
attribute :content_type, aliases: 'contentType'
|
7
7
|
attribute :file_id, aliases: 'fileId'
|
8
8
|
attribute :file_info, aliases: 'fileInfo'
|
@@ -1,5 +1,5 @@
|
|
1
|
-
class Fog::Storage::
|
2
|
-
model Fog::Storage::
|
1
|
+
class Fog::Backblaze::Storage::Files < Fog::Collection
|
2
|
+
model Fog::Backblaze::Storage::File
|
3
3
|
|
4
4
|
attribute :directory
|
5
5
|
#attribute :common_prefixes, :aliases => "CommonPrefixes"
|
@@ -8,7 +8,7 @@ class Fog::Storage::Backblaze::Files < Fog::Collection
|
|
8
8
|
#attribute :max_results, :aliases => ["MaxKeys", "max-keys"]
|
9
9
|
#attribute :prefix, :aliases => "Prefix"
|
10
10
|
|
11
|
-
model Fog::Storage::
|
11
|
+
model Fog::Backblaze::Storage::File
|
12
12
|
|
13
13
|
def all(options = {})
|
14
14
|
requires :directory
|
@@ -46,7 +46,7 @@ class Fog::Storage::Backblaze::Files < Fog::Collection
|
|
46
46
|
def head(file_name, options = {})
|
47
47
|
requires :directory
|
48
48
|
data = service.head_object(directory.key, file_name, options)
|
49
|
-
file_data = _headers_to_attrs(
|
49
|
+
file_data = _headers_to_attrs(data)
|
50
50
|
new(file_data)
|
51
51
|
rescue Excon::Errors::NotFound
|
52
52
|
nil
|
@@ -54,11 +54,11 @@ class Fog::Storage::Backblaze::Files < Fog::Collection
|
|
54
54
|
|
55
55
|
def _headers_to_attrs(file_response)
|
56
56
|
{
|
57
|
-
fileName
|
58
|
-
fileId
|
59
|
-
uploadTimestamp
|
60
|
-
contentType
|
61
|
-
contentLength
|
57
|
+
'fileName' => file_response.headers['x-bz-file-name'],
|
58
|
+
'fileId' => file_response.headers['x-bz-file-id'],
|
59
|
+
'uploadTimestamp' => file_response.headers['X-Bz-Upload-Timestamp'],
|
60
|
+
'contentType' => file_response.headers['Content-Type'],
|
61
|
+
'contentLength' => file_response.headers['Content-Length']
|
62
62
|
}
|
63
63
|
end
|
64
64
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Fog::Storage::
|
1
|
+
class Fog::Backblaze::Storage::Real
|
2
2
|
attr_reader :token_cache, :options
|
3
3
|
|
4
4
|
def initialize(options = {})
|
@@ -145,7 +145,7 @@ class Fog::Storage::Backblaze::Real
|
|
145
145
|
}.merge(options))
|
146
146
|
end
|
147
147
|
|
148
|
-
def head_object(bucket_name, file_path)
|
148
|
+
def head_object(bucket_name, file_path, options = {})
|
149
149
|
file_url = get_object_url(bucket_name, file_path)
|
150
150
|
|
151
151
|
result = b2_command(nil,
|
@@ -443,7 +443,7 @@ class Fog::Storage::Backblaze::Real
|
|
443
443
|
options[:headers]['Authorization'] ||= auth_response['authorizationToken']
|
444
444
|
|
445
445
|
if options[:body] && !options[:body].is_a?(String)
|
446
|
-
options[:body] = JSON.generate(options[:body])
|
446
|
+
options[:body] = ::JSON.generate(options[:body])
|
447
447
|
end
|
448
448
|
|
449
449
|
request_url = options.delete(:url) || "#{auth_response['apiUrl']}/b2api/v1/#{command}"
|
@@ -473,7 +473,7 @@ class Fog::Storage::Backblaze::Real
|
|
473
473
|
end
|
474
474
|
|
475
475
|
http_response.extend(Fog::Backblaze::JSONResponse)
|
476
|
-
if http_response.
|
476
|
+
if http_response.json_response? && http_response.body.size > 0
|
477
477
|
http_response.assign_json_body!
|
478
478
|
end
|
479
479
|
|
@@ -22,6 +22,8 @@
|
|
22
22
|
# Fog::Storage.new(provider: 'backblaze', ..., token_cache: RedisTokenCache.new)
|
23
23
|
#
|
24
24
|
|
25
|
+
require 'json'
|
26
|
+
|
25
27
|
class Fog::Backblaze::TokenCache
|
26
28
|
|
27
29
|
def initialize
|
@@ -116,7 +118,7 @@ class Fog::Backblaze::TokenCache
|
|
116
118
|
|
117
119
|
def save_data
|
118
120
|
File.open(@file, 'wb') do |f|
|
119
|
-
f.write(JSON.pretty_generate(@data) + "\n")
|
121
|
+
f.write(::JSON.pretty_generate(@data) + "\n")
|
120
122
|
end
|
121
123
|
end
|
122
124
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-backblaze
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Evstigneev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-core
|
@@ -52,15 +52,15 @@ files:
|
|
52
52
|
- fog-backblaze.gemspec
|
53
53
|
- lib/fog/backblaze.rb
|
54
54
|
- lib/fog/backblaze/json_response.rb
|
55
|
+
- lib/fog/backblaze/storage.rb
|
56
|
+
- lib/fog/backblaze/storage/mock.rb
|
57
|
+
- lib/fog/backblaze/storage/models/directories.rb
|
58
|
+
- lib/fog/backblaze/storage/models/directory.rb
|
59
|
+
- lib/fog/backblaze/storage/models/file.rb
|
60
|
+
- lib/fog/backblaze/storage/models/files.rb
|
61
|
+
- lib/fog/backblaze/storage/real.rb
|
55
62
|
- lib/fog/backblaze/token_cache.rb
|
56
63
|
- lib/fog/backblaze/version.rb
|
57
|
-
- lib/fog/storage/backblaze.rb
|
58
|
-
- lib/fog/storage/backblaze/mock.rb
|
59
|
-
- lib/fog/storage/backblaze/models/directories.rb
|
60
|
-
- lib/fog/storage/backblaze/models/directory.rb
|
61
|
-
- lib/fog/storage/backblaze/models/file.rb
|
62
|
-
- lib/fog/storage/backblaze/models/files.rb
|
63
|
-
- lib/fog/storage/backblaze/real.rb
|
64
64
|
homepage: https://github.com/fog/fog-backblaze
|
65
65
|
licenses: []
|
66
66
|
metadata: {}
|
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
82
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.6.
|
83
|
+
rubygems_version: 2.7.6.2
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: Module for the 'fog' gem to support Blackblade B2 stogate.
|