activestorage-aliyun 0.4.1 → 0.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04e1265400dd3a5203a08928630037e34b75e1fb0e225c209228d7bb42330671
4
- data.tar.gz: ae3ab3f2ddf9f71994ba5798b0f10f4130a2c6fd245fe50dba0c6a0bacb96fd4
3
+ metadata.gz: f817ca04a1433ea1f3b224ed89dfcd53802b2a15d2e2d35430724bb805ba8c26
4
+ data.tar.gz: f64560d7102526397c87a0255267521c17d854b13ee212dcff54730b233f24f0
5
5
  SHA512:
6
- metadata.gz: 33d3f92832c8f21dc890eb682e0e949fe50efc7066f2320bdaf11a16b98fe42ca90aa0ac87bc37bec6d1f6a898c0bc8c5939ab1693425f7078f49c5d59e9d337
7
- data.tar.gz: 6670c6fcace9bacc6cf806d32d2922e2a73c533a0ee1945fddff7815cc10be94d28bd50fcc2a29dcdc1bb267dfb6a1cd78d844f3be0ebdb9583349e8cce4f136
6
+ metadata.gz: 532f0a1b89d68bebf9e70f95ac645ff47db09a977f085d995d6ff30cf587089248ccc05736fbdc0998fd8586d1b2dc4324a2d4af0557dfe5c5bab16d57865358
7
+ data.tar.gz: db1561aace0805c0e0b29adaa167d789de227e016d8afde47a81902004aad5606a1a2114d37f6a4e52d8e7fd9f5f41fa009fea0ce683cecc9ab4b0f2db163720
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.5.0
2
+
3
+ - Implement download_chunk method for fix #10 upload a large file by directly.
4
+
1
5
  ## 0.4.1
2
6
 
3
7
  - Remove config.path `/` prefix for fix #7 issue.
data/README.md CHANGED
@@ -72,7 +72,13 @@ If you want to get original filename (Include Chinese and other UTF-8 chars), fo
72
72
 
73
73
  ## Contributing
74
74
 
75
- Contribution directions go here.
75
+ ### Run test
76
+
77
+ ```bash
78
+ $ bin/test test/activestorage_aliyun_test.rb
79
+ # run a line
80
+ $ bin/test test/activestorage_aliyun_test.rb:129
81
+ ```
76
82
 
77
83
  ## License
78
84
 
@@ -16,15 +16,28 @@ module ActiveStorage
16
16
  end
17
17
  end
18
18
 
19
- def download(key)
20
- instrument :download, key: key do
21
- chunk_buff = []
22
- bucket.get_object(path_for(key)) do |chunk|
23
- if block_given?
24
- yield chunk
25
- else
19
+ def download(key, &block)
20
+ if block_given?
21
+ instrument :streaming_download, key: key do
22
+ bucket.get_object(path_for(key), &block)
23
+ end
24
+ else
25
+ instrument :download, key: key do
26
+ chunk_buff = []
27
+ bucket.get_object(path_for(key)) do |chunk|
26
28
  chunk_buff << chunk
27
29
  end
30
+ chunk_buff.join("")
31
+ end
32
+ end
33
+ end
34
+
35
+ def download_chunk(key, range)
36
+ instrument :download_chunk, key: key, range: range do
37
+ chunk_buff = []
38
+ range_end = range.exclude_end? ? range.end : range.end + 1
39
+ bucket.get_object(path_for(key), range: [range.begin, range_end]) do |chunk|
40
+ chunk_buff << chunk
28
41
  end
29
42
  chunk_buff.join("")
30
43
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveStorageAliyun
2
- VERSION = '0.4.1'
2
+ VERSION = '0.5.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activestorage-aliyun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee