bkblz 0.1.11 → 0.1.12
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/.gitignore +1 -0
- data/README.rb +7 -1
- data/bin/bkblz +3 -1
- data/lib/bkblz/task/upload_file.rb +19 -2
- 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: 67343da9ff4b13623a47edc49f3d2d00b68d1d4f
|
|
4
|
+
data.tar.gz: 8ae1e66f110945ab489e2f05667fddc6d922b0af
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 224f37da1dd4adad73ca36becd793769110d278bc22230271260ffd797cffc47e1cc532154daface01e701baf98c0df197c381591668f48c61cadc2f51213695
|
|
7
|
+
data.tar.gz: 996efe932b47415ad4a8fcdac2cc5283620510c147fbca8e1229b923489f1f6d840284f414c4719e6e53838bd07293dfa7473bbe29a3b4b2aa5a63c4c905cf80
|
data/.gitignore
CHANGED
data/README.rb
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
=begin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
tldr:
|
|
4
|
+
$ gem install bkblz
|
|
5
|
+
$ bkblz help
|
|
6
|
+
|
|
7
|
+
More...
|
|
8
|
+
|
|
9
|
+
This is the bkblz Ruby gem, a library for the Backblaze B2 cloud
|
|
4
10
|
storage API: https://www.backblaze.com/b2/docs/
|
|
5
11
|
|
|
6
12
|
Currently the gem supports the following V1 API calls:
|
data/bin/bkblz
CHANGED
|
@@ -113,12 +113,14 @@ module Bkblz
|
|
|
113
113
|
" if <local_file_path> is \"-\" (0x2d), then upload will read from STDIN."
|
|
114
114
|
option :file_name, :desc => "remote file name, if not given the basename" +
|
|
115
115
|
" of the local file is used"
|
|
116
|
+
option :gzip, :type => :boolean, :desc => "automatically gzip files"
|
|
116
117
|
def upload(bucket_name, local_file_path)
|
|
117
118
|
parse_opts
|
|
118
119
|
|
|
119
120
|
params = {
|
|
120
121
|
:bucket_name => bucket_name,
|
|
121
|
-
:file_name => options[:file_name]
|
|
122
|
+
:file_name => options[:file_name],
|
|
123
|
+
:gzip => options[:gzip]
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
if local_file_path == "-"
|
|
@@ -1,11 +1,22 @@
|
|
|
1
|
+
require 'zlib'
|
|
2
|
+
|
|
1
3
|
module Bkblz
|
|
2
4
|
module Task
|
|
3
5
|
class UploadFile < BaseTask
|
|
4
6
|
|
|
5
7
|
task_param :bucket_name, :required => true
|
|
6
|
-
|
|
8
|
+
|
|
9
|
+
# Either file_body or file_path is required
|
|
10
|
+
task_param :file_body
|
|
11
|
+
|
|
7
12
|
task_param :file_path
|
|
8
|
-
|
|
13
|
+
|
|
14
|
+
# Overrides local file_path if given
|
|
15
|
+
task_param :file_name
|
|
16
|
+
|
|
17
|
+
# Use gzip default compression before writing to b2 the file name will be
|
|
18
|
+
# updated by appending ".gz"
|
|
19
|
+
task_param :gzip
|
|
9
20
|
|
|
10
21
|
def run_internal(session, params)
|
|
11
22
|
file_body = if params[:file_path]
|
|
@@ -31,6 +42,12 @@ module Bkblz
|
|
|
31
42
|
Time.now
|
|
32
43
|
end.to_i * 1000
|
|
33
44
|
|
|
45
|
+
if params[:gzip]
|
|
46
|
+
# https://ruby-doc.org/stdlib-2.4.2/libdoc/zlib/rdoc/Zlib.html#method-c-gzip
|
|
47
|
+
file_body = Zlib.gzip file_body, level: Zlib::DEFAULT_COMPRESSION
|
|
48
|
+
file_name << ".gz" unless file_name =~ /\.gz$/
|
|
49
|
+
end
|
|
50
|
+
|
|
34
51
|
bucket = find_bucket_by_name session, params[:bucket_name]
|
|
35
52
|
upload_auth = session.send(
|
|
36
53
|
Bkblz::V1::GetUploadUrlRequest.new bucket.bucket_id).to_model
|
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.12
|
|
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-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|