bkblz 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/bkblz +12 -4
- data/lib/bkblz/task/list_files.rb +4 -1
- data/lib/bkblz/task/upload_file.rb +4 -1
- data/lib/bkblz/v1/list_file_names.rb +6 -1
- data/lib/bkblz/v1/response.rb +2 -1
- data/lib/bkblz/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a78f7af9b064373a818c24c9f74c5402a153317f
|
4
|
+
data.tar.gz: 76c95a222b762d6b741313849c92be7162546aa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '028ede1e92325f7808d1dc3769f8c29b9ac4017bd50ff26205e90bcb6cb6ed288e3f13765f2f11262c5d7a58700b4782fef4f7a9ea0f4d37e56fb1941bf5c3ff'
|
7
|
+
data.tar.gz: 9ba3b10ead315fced6c2ab188fa75db3544bfe2da810f662955f0583c285cd33efa10d2138d8bb9cac5f6df07aee9414257fb8f3655dd8a5eac6a5faab4c56a5
|
data/bin/bkblz
CHANGED
@@ -110,14 +110,17 @@ module Bkblz
|
|
110
110
|
include Helper
|
111
111
|
|
112
112
|
desc "upload <bucket_name> <local_file_path>", "upload a local file to B2"
|
113
|
+
option :file_name, :desc => "remote file name, if not given the basename" +
|
114
|
+
"of the local file is used"
|
113
115
|
def upload(bucket_name, local_file_path)
|
114
116
|
parse_opts
|
115
117
|
|
116
118
|
file_info = run_task do
|
117
119
|
Bkblz::Task::UploadFile.run Bkblz.config, {
|
118
|
-
|
119
|
-
|
120
|
-
|
120
|
+
:bucket_name => bucket_name,
|
121
|
+
:file_path => local_file_path,
|
122
|
+
:file_name => options[:file_name]
|
123
|
+
}
|
121
124
|
end
|
122
125
|
|
123
126
|
print_header "File Info"
|
@@ -148,6 +151,9 @@ module Bkblz
|
|
148
151
|
}
|
149
152
|
option :all, :desc => "lists all file versions, cannot be used with --start-at"
|
150
153
|
option :with_id, :type => :boolean, :desc => "include file_id in results"
|
154
|
+
option :prefix, :desc => "limits results to those that match the prefix"
|
155
|
+
option :delimiter, :desc => "combine with prefix to search directories, " +
|
156
|
+
"see https://www.backblaze.com/b2/docs/b2_list_file_names.html for usage"
|
151
157
|
def list(bucket_name)
|
152
158
|
parse_opts
|
153
159
|
|
@@ -158,7 +164,9 @@ module Bkblz
|
|
158
164
|
:start_at => options[:start_at],
|
159
165
|
:limit => options[:limit],
|
160
166
|
:all_versions => options[:all],
|
161
|
-
:bucket_name => bucket_name
|
167
|
+
:bucket_name => bucket_name,
|
168
|
+
:prefix => options[:prefix],
|
169
|
+
:delimiter => options[:delimiter]
|
162
170
|
})
|
163
171
|
|
164
172
|
file_printer = lambda do |file|
|
@@ -6,6 +6,8 @@ module Bkblz
|
|
6
6
|
task_param :limit, :default => 100
|
7
7
|
task_param :all_versions
|
8
8
|
task_param :bucket_name, :required => true
|
9
|
+
task_param :prefix
|
10
|
+
task_param :delimiter
|
9
11
|
|
10
12
|
def run_internal(session, params)
|
11
13
|
bucket = find_bucket_by_name session, params[:bucket_name]
|
@@ -14,7 +16,8 @@ module Bkblz
|
|
14
16
|
session.send Bkblz::V1::ListFileVersionsRequest.new bucket, params[:limit]
|
15
17
|
else
|
16
18
|
session.send Bkblz::V1::ListFileNamesRequest.new(
|
17
|
-
|
19
|
+
bucket, params[:limit], params[:start_at],
|
20
|
+
:prefix => params[:prefix], :delimiter => params[:delimiter])
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
@@ -4,7 +4,10 @@ module Bkblz
|
|
4
4
|
|
5
5
|
task_param :bucket_name, :required => true
|
6
6
|
task_param :file_path, :required => true
|
7
|
+
task_param :file_name # Overrides local file_path if given
|
7
8
|
|
9
|
+
# TODO(erick): Change file_path to a byte string, let the task be agnostic
|
10
|
+
# to where the data comes from. (Probably v0.2).
|
8
11
|
def run_internal(session, params)
|
9
12
|
f = ::File.new(params[:file_path], "r")
|
10
13
|
|
@@ -12,7 +15,7 @@ module Bkblz
|
|
12
15
|
upload_auth = session.send(
|
13
16
|
Bkblz::V1::GetUploadUrlRequest.new bucket.bucket_id).to_model
|
14
17
|
|
15
|
-
file_name = ::File.basename
|
18
|
+
file_name = params[:file_name] || ::File.basename(f.path)
|
16
19
|
file_body = f.read
|
17
20
|
mtime_millis = f.mtime.to_i * 1000
|
18
21
|
|
@@ -12,6 +12,7 @@ module Bkblz
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
# https://www.backblaze.com/b2/docs/b2_list_file_names.html
|
15
16
|
class ListFileNamesRequest < Request
|
16
17
|
|
17
18
|
response_class ListFileNamesResponse
|
@@ -19,12 +20,16 @@ module Bkblz
|
|
19
20
|
|
20
21
|
attr_reader :bucket
|
21
22
|
|
22
|
-
|
23
|
+
# TODO(erick): Switch start_file_name to a keyword arg
|
24
|
+
def initialize(bucket, max_file_count=1000, start_file_name=nil,
|
25
|
+
prefix: nil, delimiter: nil)
|
23
26
|
@bucket = bucket
|
24
27
|
@body = {}
|
25
28
|
@body[:bucket_id] = bucket.bucket_id
|
26
29
|
@body[:max_file_count] = max_file_count
|
27
30
|
@body[:start_file_name] = start_file_name if start_file_name
|
31
|
+
@body[:prefix] = prefix if prefix
|
32
|
+
@body[:delimiter] = delimiter if delimiter
|
28
33
|
end
|
29
34
|
|
30
35
|
def build_request(session)
|
data/lib/bkblz/v1/response.rb
CHANGED
@@ -74,7 +74,8 @@ module Bkblz
|
|
74
74
|
parsed_json = JSON.parse http_response.body, {
|
75
75
|
:allow_nan => true,
|
76
76
|
:symbolize_names => true,
|
77
|
-
:
|
77
|
+
# TODO(erick): Maybe make this configurable?
|
78
|
+
:max_nesting => 10
|
78
79
|
}
|
79
80
|
Bkblz::MapKeyFormatter.underscore_keys parsed_json
|
80
81
|
end
|
data/lib/bkblz/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bkblz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erick Johnson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
139
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.
|
140
|
+
rubygems_version: 2.6.13
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Bkblz GEM for the Backblaze B2 API. https://www.backblaze.com/b2/docs/
|