bkblz 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/bkblz +21 -1
- data/lib/bkblz/task/download_file.rb +32 -5
- data/lib/bkblz/v1/download_file.rb +2 -1
- data/lib/bkblz/v1/session.rb +5 -0
- data/lib/bkblz/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 276cd7b864f9a13fd8a32ea5839514f041afbd02
|
4
|
+
data.tar.gz: c87c7242a87241a7b6e48f3bef5aab55117ef37b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ac0e9aa47318c48169be640350dede4d116d83b15980520b99289e19ea9b1ae7a2ae79c5a24a8e3c0e92f3dc7733e311888630b099ff150705a293a77715d10
|
7
|
+
data.tar.gz: 53ac8463bd04b6a747f853837f825a6cb1908c1c55cefa837c472e0a83f575f12933969ed540ffb40fa9aad7c7d6a8f64f9553eca91ae4e3330c4366087c9956
|
data/bin/bkblz
CHANGED
@@ -127,6 +127,25 @@ module Bkblz
|
|
127
127
|
print_model file_info
|
128
128
|
end
|
129
129
|
|
130
|
+
desc "downloadbyname <bucket> <name> <dir>", "downloads file by <bucket> " +
|
131
|
+
"and <name> to directory <dir>"
|
132
|
+
def downloadbyname(bucket_name, file_name, dir_path)
|
133
|
+
parse_opts
|
134
|
+
|
135
|
+
file_info = run_task do
|
136
|
+
Bkblz::Task::DownloadFile.run Bkblz.config, {
|
137
|
+
:file_name => file_name,
|
138
|
+
:bucket_name => bucket_name,
|
139
|
+
:dir_path => dir_path,
|
140
|
+
:use_filename => true
|
141
|
+
}
|
142
|
+
end
|
143
|
+
|
144
|
+
print_header "File Info"
|
145
|
+
print_model file_info
|
146
|
+
end
|
147
|
+
|
148
|
+
# TODO(erick): Rename to downloadbyid
|
130
149
|
desc "download <id> <dir>", "downloads file <id> to directory <dir>"
|
131
150
|
def download(file_id, dir_path)
|
132
151
|
parse_opts
|
@@ -134,7 +153,8 @@ module Bkblz
|
|
134
153
|
file_info = run_task do
|
135
154
|
Bkblz::Task::DownloadFile.run Bkblz.config, {
|
136
155
|
:file_id => file_id,
|
137
|
-
:dir_path => dir_path
|
156
|
+
:dir_path => dir_path,
|
157
|
+
:use_filename => options[:by_name]
|
138
158
|
}
|
139
159
|
end
|
140
160
|
|
@@ -4,14 +4,22 @@ module Bkblz
|
|
4
4
|
module Task
|
5
5
|
class DownloadFile < BaseTask
|
6
6
|
|
7
|
-
task_param :file_id, :required => true
|
8
7
|
task_param :dir_path, :required => true
|
9
8
|
|
9
|
+
# for downalod by id
|
10
|
+
task_param :file_id
|
11
|
+
|
12
|
+
# for download by name
|
13
|
+
task_param :bucket_name
|
14
|
+
task_param :file_name
|
15
|
+
task_param :use_filename
|
16
|
+
|
10
17
|
def run_internal(session, params)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
18
|
+
download_file_info = if params[:use_filename]
|
19
|
+
download_by_name(session, params)
|
20
|
+
else
|
21
|
+
download_by_id(session, params)
|
22
|
+
end
|
15
23
|
|
16
24
|
unless download_file_info.sha1 == Digest::SHA1.hexdigest(download_file_info.body)
|
17
25
|
raise "invalid checksum"
|
@@ -37,6 +45,25 @@ module Bkblz
|
|
37
45
|
map[:body] = "<omitted>"
|
38
46
|
Bkblz::V1::Model::FileDownload.new map
|
39
47
|
end
|
48
|
+
|
49
|
+
def download_by_name(session, params)
|
50
|
+
raise 'missing file name' unless params[:file_name]
|
51
|
+
raise 'missing bucket name' unless params[:bucket_name]
|
52
|
+
|
53
|
+
bucket = find_bucket_by_name session, params[:bucket_name]
|
54
|
+
file = params[:file_name]
|
55
|
+
session.send(
|
56
|
+
Bkblz::V1::DownloadFileByNameRequest.new bucket, file).to_model
|
57
|
+
end
|
58
|
+
|
59
|
+
def download_by_id(session, params)
|
60
|
+
raise 'missing file id' unless params[:file_id]
|
61
|
+
|
62
|
+
partial_file_info =
|
63
|
+
Bkblz::V1::Model::PartialFileInfo.new :file_id => params[:file_id]
|
64
|
+
session.send(
|
65
|
+
Bkblz::V1::DownloadFileByIdRequest.new partial_file_info).to_model
|
66
|
+
end
|
40
67
|
end
|
41
68
|
end
|
42
69
|
end
|
data/lib/bkblz/v1/session.rb
CHANGED
@@ -37,6 +37,11 @@ module Bkblz
|
|
37
37
|
!!auth_response && !!auth_response.authorization_token
|
38
38
|
end
|
39
39
|
|
40
|
+
def create_download_url(url_suffix)
|
41
|
+
check_authorized
|
42
|
+
URI.join auth_response.download_url, url_suffix
|
43
|
+
end
|
44
|
+
|
40
45
|
def create_url(url_suffix)
|
41
46
|
check_authorized
|
42
47
|
URI.join auth_response.api_url, url_suffix
|
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.9
|
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-
|
11
|
+
date: 2017-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|