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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +7 -1
- data/lib/active_storage/service/aliyun_service.rb +20 -7
- data/lib/active_storage_aliyun/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f817ca04a1433ea1f3b224ed89dfcd53802b2a15d2e2d35430724bb805ba8c26
|
4
|
+
data.tar.gz: f64560d7102526397c87a0255267521c17d854b13ee212dcff54730b233f24f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 532f0a1b89d68bebf9e70f95ac645ff47db09a977f085d995d6ff30cf587089248ccc05736fbdc0998fd8586d1b2dc4324a2d4af0557dfe5c5bab16d57865358
|
7
|
+
data.tar.gz: db1561aace0805c0e0b29adaa167d789de227e016d8afde47a81902004aad5606a1a2114d37f6a4e52d8e7fd9f5f41fa009fea0ce683cecc9ab4b0f2db163720
|
data/CHANGELOG.md
CHANGED
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
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|