carrierwave-aliyun 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -0
- data/Changelogs.md +4 -0
- data/README.md +5 -1
- data/lib/carrierwave/aliyun/configuration.rb +1 -0
- data/lib/carrierwave/aliyun/version.rb +1 -1
- data/lib/carrierwave/storage/aliyun.rb +5 -3
- data/spec/aliyun_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c88a9af587b855318be9ced43af6fd29e964f40
|
4
|
+
data.tar.gz: ecab21ea3488317eeb406fdf71024181e1610328
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37a7b3e42a51bae11d7cd9f829c827f4eea442e79aa34895e835a3a95203a37702f1d1a6a9fde48eed1afa9346e0d70486a378ddac37f89c4caf21f958e36315
|
7
|
+
data.tar.gz: e9418dafc9f763fc80006d13e99a5c968349a06fbb3b7675944eb99d7927de4fde32e680e2a3270cb7b12f1bd8f69837813fb838415c5cb73b6d268f59e5c3fa
|
data/.travis.yml
ADDED
data/Changelogs.md
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
This gem adds support for [Aliyun OSS](http://oss.aliyun.com) to [CarrierWave](https://github.com/jnicklas/carrierwave/)
|
4
4
|
|
5
|
+
- [![Gem Version](https://badge.fury.io/rb/carrierwave-aliyun.png)](https://rubygems.org/gems/carrierwave-aliyun)
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
```bash
|
@@ -28,6 +30,8 @@ CarrierWave.configure do |config|
|
|
28
30
|
config.aliyun_bucket = "simple"
|
29
31
|
# 是否使用内部连接,true - 使用 Aliyun 局域网的方式访问 false - 外部网络访问
|
30
32
|
config.aliyun_internal = true
|
33
|
+
# 配置存储的地区数据中心,默认: cn-hangzhou
|
34
|
+
# config.aliyun_area = "cn-hangzhou"
|
31
35
|
# 使用自定义域名,设定此项,carrierwave 返回的 URL 将会用自定义域名
|
32
36
|
# 自定于域名请 CNAME 到 you_bucket_name.oss.aliyuncs.com (you_bucket_name 是你的 bucket 的名称)
|
33
37
|
config.aliyun_host = "foo.bar.com"
|
@@ -36,4 +40,4 @@ end
|
|
36
40
|
|
37
41
|
## 跳过 CarrierWave 直接调用 Aliyun API
|
38
42
|
|
39
|
-
如果你有需求想跳过 CarrierWave,直接调用 Aliyun 的接口,可以参看 `spec/aliyun_spec.rb` 里面有例子。
|
43
|
+
如果你有需求想跳过 CarrierWave,直接调用 Aliyun 的接口,可以参看 `spec/aliyun_spec.rb` 里面有例子。
|
@@ -14,13 +14,14 @@ module CarrierWave
|
|
14
14
|
@aliyun_access_id = options[:aliyun_access_id]
|
15
15
|
@aliyun_access_key = options[:aliyun_access_key]
|
16
16
|
@aliyun_bucket = options[:aliyun_bucket]
|
17
|
+
@aliyun_area = options[:aliyun_area] || 'cn-hangzhou'
|
17
18
|
# Host for upload
|
18
|
-
@aliyun_upload_host = "#{@aliyun_bucket}.oss.aliyuncs.com"
|
19
|
+
@aliyun_upload_host = "#{@aliyun_bucket}.oss-#{@aliyun_area}.aliyuncs.com"
|
19
20
|
if options[:aliyun_internal] == true
|
20
|
-
@aliyun_upload_host = "#{@aliyun_bucket}.oss-internal.aliyuncs.com"
|
21
|
+
@aliyun_upload_host = "#{@aliyun_bucket}.oss-#{@aliyun_area}-internal.aliyuncs.com"
|
21
22
|
end
|
22
23
|
# Host for get request
|
23
|
-
@aliyun_host = options[:aliyun_host] || "#{@aliyun_bucket}.oss.aliyuncs.com"
|
24
|
+
@aliyun_host = options[:aliyun_host] || "#{@aliyun_bucket}.oss-#{@aliyun_area}.aliyuncs.com"
|
24
25
|
end
|
25
26
|
|
26
27
|
=begin rdoc
|
@@ -185,6 +186,7 @@ module CarrierWave
|
|
185
186
|
config = {
|
186
187
|
:aliyun_access_id => @uploader.aliyun_access_id,
|
187
188
|
:aliyun_access_key => @uploader.aliyun_access_key,
|
189
|
+
:aliyun_area => @uploader.aliyun_area,
|
188
190
|
:aliyun_bucket => @uploader.aliyun_bucket,
|
189
191
|
:aliyun_internal => @uploader.aliyun_internal,
|
190
192
|
:aliyun_host => @uploader.aliyun_host
|
data/spec/aliyun_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe "Aliyun" do
|
|
11
11
|
}
|
12
12
|
@connection = CarrierWave::Storage::Aliyun::Connection.new(@opts)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
it "should put" do
|
16
16
|
url = @connection.put("a/a.jpg",load_file("foo.jpg"))
|
17
17
|
Net::HTTP.get_response(URI.parse(url)).code.should == "200"
|
@@ -29,7 +29,7 @@ describe "Aliyun" do
|
|
29
29
|
|
30
30
|
it "should use default domain" do
|
31
31
|
url = @connection.put("a/a.jpg",load_file("foo.jpg"))
|
32
|
-
url.should == "http://#{ALIYUN_BUCKET}.oss.aliyuncs.com/a/a.jpg"
|
32
|
+
url.should == "http://#{ALIYUN_BUCKET}.oss-cn-hangzhou.aliyuncs.com/a/a.jpg"
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should support custom domain" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-aliyun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|
@@ -47,6 +47,7 @@ extra_rdoc_files: []
|
|
47
47
|
files:
|
48
48
|
- .gitignore
|
49
49
|
- .rspec
|
50
|
+
- .travis.yml
|
50
51
|
- Changelogs.md
|
51
52
|
- Gemfile
|
52
53
|
- README.md
|
@@ -81,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
82
|
version: '0'
|
82
83
|
requirements: []
|
83
84
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.
|
85
|
+
rubygems_version: 2.1.11
|
85
86
|
signing_key:
|
86
87
|
specification_version: 4
|
87
88
|
summary: Aliyun OSS support for Carrierwave
|
@@ -92,4 +93,3 @@ test_files:
|
|
92
93
|
- spec/foo.zip
|
93
94
|
- spec/spec_helper.rb
|
94
95
|
- spec/upload_spec.rb
|
95
|
-
has_rdoc:
|