carrierwave_ucloud 0.2.2 → 0.2.3
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/README.md +4 -2
- data/lib/carrierwave/storage/ucloud_file.rb +9 -0
- data/lib/carrierwave/ucloud/bucket.rb +12 -4
- data/lib/carrierwave_ucloud/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc20df7903855c3d399b3fa234924e1cf09e37d19bd1752daf28c84dae6909bd
|
4
|
+
data.tar.gz: 4da0af883fc46a0f3d8a40d4c0e581cde968bae3b29e2458e78fd489b376955d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f2f2f52fafbecf97b220a545468c68e7edda1c3bde0ea0ceb69cd9ef69ae38f0b2307d2171356477acd99d6622ff5fb1dfc39a0ce686f5f21ce676bef547ae1
|
7
|
+
data.tar.gz: a6deb49798c491752a2baddb55b7c9adfe35be7a0c535e6a91edd76c2a9888ebd369f9fa8b55e28d0545d928aa58a1a3630649b6433660d11aab8c96aed4ad46
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ Ucloud Ufile CarrierWave Gem。
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem 'carrierwave_ucloud', '0.2.
|
12
|
+
gem 'carrierwave_ucloud', '0.2.2'
|
13
13
|
```
|
14
14
|
|
15
15
|
And then execute:
|
@@ -25,7 +25,7 @@ Or install it yourself as:
|
|
25
25
|
配置文件:config/initializers/carrierwave.rb,内容如下:
|
26
26
|
|
27
27
|
```ruby
|
28
|
-
# public / private
|
28
|
+
# public / private 最少配置一套,配置2套可共存,uploader文件ucloud_public_read自己要对应好,暂时没有做任何校验逻辑
|
29
29
|
CarrierWave.configure do |config|
|
30
30
|
config.storage = :ucloud
|
31
31
|
config.ucloud_public_key = "public_key"
|
@@ -33,10 +33,12 @@ CarrierWave.configure do |config|
|
|
33
33
|
config.ucloud_public_read = true # 默认使用public bucket,可在单个uploader覆写
|
34
34
|
# public bucket配置
|
35
35
|
config.ucloud_public_bucket = "public_bucket_name"
|
36
|
+
# bucket 上传host,可设置ucloud提供的纯内网host(每个区不一样,例如:"http://public_bucket_name.ufile.cn-north-02.ucloud.cn"),或者配置和cdn访问host一样的
|
36
37
|
config.ucloud_public_bucket_host = "http://public_bucket_name.cn-bj.ufileos.com"
|
37
38
|
config.ucloud_public_cdn_host = "http://public_bucket_name.cn-bj.ufileos.com"
|
38
39
|
config.ucloud_private_bucket = "private_bucket_name"
|
39
40
|
# private bucket配置
|
41
|
+
# bucket 上传host,可设置ucloud提供的纯内网host(每个区不一样,例如:"http://private_bucket_name.ufile.cn-north-02.ucloud.cn"),或者配置和cdn访问host一样的
|
40
42
|
config.ucloud_private_bucket_host = "http://private_bucket_name.cn-bj.ufileos.com"
|
41
43
|
config.ucloud_private_cdn_host = "http://private_bucket_name.cn-bj.ufileos.com"
|
42
44
|
config.ucloud_private_expire_seconds = 300
|
@@ -10,6 +10,15 @@ module CarrierWave
|
|
10
10
|
@bucket = ::CarrierWave::Ucloud::Bucket.new(uploader)
|
11
11
|
end
|
12
12
|
|
13
|
+
##
|
14
|
+
# === Returns
|
15
|
+
#
|
16
|
+
# [Boolean] Whether the file exists
|
17
|
+
#
|
18
|
+
def exists?
|
19
|
+
bucket.exists?(path)
|
20
|
+
end
|
21
|
+
|
13
22
|
def read
|
14
23
|
response = bucket.get(path)
|
15
24
|
@headers = response.headers.deep_transform_keys { |k| k.underscore.to_sym rescue key }
|
@@ -51,17 +51,25 @@ module CarrierWave
|
|
51
51
|
end
|
52
52
|
|
53
53
|
# 删除文件
|
54
|
+
# @return [Boolean]
|
54
55
|
def delete(path)
|
55
56
|
path.sub!(PATH_PREFIX, '')
|
56
57
|
response = conn.delete(url(path)) do |req|
|
57
58
|
req.headers['Authorization'] = authorization(req.method, nil, path)
|
58
59
|
end
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
response.success?
|
62
|
+
end
|
63
|
+
|
64
|
+
# 查看文件是否存在(head response 200)
|
65
|
+
# @return [Boolean]
|
66
|
+
def exists?(path)
|
67
|
+
path.sub!(PATH_PREFIX, '')
|
68
|
+
response = conn.head(url(path)) do |req|
|
69
|
+
req.headers['Authorization'] = authorization(req.method, nil, path)
|
64
70
|
end
|
71
|
+
|
72
|
+
response.success?
|
65
73
|
end
|
66
74
|
|
67
75
|
def url(path)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave_ucloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zhchsf
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|