carrierwave-aliyun 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/carrierwave/aliyun/version.rb +1 -1
- data/lib/carrierwave/storage/aliyun.rb +6 -2
- data/spec/aliyun_spec.rb +13 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 552fc80ab3151b427003443f8494970253c87db4
|
4
|
+
data.tar.gz: 15d4f27db9d2173cda033098646ad82c21a29b20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86801d09e20af64fc5574ae94db229e806dbb2bbc63067c2c2e6a0ad9046abf1f2b361014f854ad59cb5c3a0fcd239caeb7f3fdab9d6d57b7b6bf5f77c2d0bbd
|
7
|
+
data.tar.gz: 7a71ecb5d1d1c1428cd00d37b9f04dd05b45a5bd6e9cd7210ce20a827bf11a945683f227d640af02ff4646708a9062b0fa02998762e90cd25a03ef7001765b6d
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -15,6 +15,7 @@ module CarrierWave
|
|
15
15
|
@aliyun_bucket = uploader.aliyun_bucket
|
16
16
|
@aliyun_area = uploader.aliyun_area || 'cn-hangzhou'
|
17
17
|
@aliyun_private_read = uploader.aliyun_private_read
|
18
|
+
@aliyun_internal = uploader.aliyun_internal
|
18
19
|
|
19
20
|
# Host for get request
|
20
21
|
@aliyun_host = uploader.aliyun_host || "http://#{@aliyun_bucket}.oss-#{@aliyun_area}.aliyuncs.com"
|
@@ -125,8 +126,11 @@ module CarrierWave
|
|
125
126
|
def oss_upload_client
|
126
127
|
return @oss_upload_client if defined?(@oss_upload_client)
|
127
128
|
|
128
|
-
|
129
|
-
|
129
|
+
if @aliyun_internal
|
130
|
+
host = "oss-#{@aliyun_area}-internal.aliyuncs.com"
|
131
|
+
else
|
132
|
+
host = "oss-#{@aliyun_area}.aliyuncs.com"
|
133
|
+
end
|
130
134
|
|
131
135
|
opts = {
|
132
136
|
host: host,
|
data/spec/aliyun_spec.rb
CHANGED
@@ -8,8 +8,8 @@ describe "Aliyun" do
|
|
8
8
|
:aliyun_access_id => ALIYUN_ACCESS_ID,
|
9
9
|
:aliyun_access_key => ALIYUN_ACCESS_KEY,
|
10
10
|
:aliyun_bucket => ALIYUN_BUCKET,
|
11
|
-
:aliyun_area =>
|
12
|
-
:aliyun_internal =>
|
11
|
+
:aliyun_area => ALIYUN_AREA,
|
12
|
+
:aliyun_internal => false,
|
13
13
|
:aliyun_host => "http://bison-dev.cn-hangzhou.oss.aliyun-inc.com"
|
14
14
|
}
|
15
15
|
|
@@ -17,6 +17,16 @@ describe "Aliyun" do
|
|
17
17
|
@connection = CarrierWave::Storage::Aliyun::Connection.new(@uploader)
|
18
18
|
end
|
19
19
|
|
20
|
+
# it "should put by internal network" do
|
21
|
+
# @uploader.aliyun_internal = true
|
22
|
+
# @connection = CarrierWave::Storage::Aliyun::Connection.new(@uploader)
|
23
|
+
# puts @connection.to_json
|
24
|
+
# url = @connection.put("/a/a.jpg",load_file("foo.jpg"))
|
25
|
+
# res = Net::HTTP.get_response(URI.parse(url))
|
26
|
+
# puts res.to_json
|
27
|
+
# expect(res.code).to eq "200"
|
28
|
+
# end
|
29
|
+
|
20
30
|
it "should put" do
|
21
31
|
url = @connection.put("a/a.jpg",load_file("foo.jpg"))
|
22
32
|
res = Net::HTTP.get_response(URI.parse(url))
|
@@ -56,7 +66,7 @@ describe "Aliyun" do
|
|
56
66
|
url = @connection.private_get_url('bar/foo.jpg')
|
57
67
|
# http://oss-cn-beijing.aliyuncs.com.//carrierwave-aliyun-test.oss-cn-beijing.aliyuncs.com/bar/foo.jpg?OSSAccessKeyId=1OpWEtPTjIDv5u8q&Expires=1455172009&Signature=4ibgQpfHOjVpqxG6162S8Ar3c6c=
|
58
68
|
expect(url).to include(*%w(Signature Expires OSSAccessKeyId))
|
59
|
-
expect(url).to include "http://#{@uploader.aliyun_bucket}.oss
|
69
|
+
expect(url).to include "http://#{@uploader.aliyun_bucket}.oss-#{@uploader.aliyun_area}.aliyuncs.com/bar/foo.jpg"
|
60
70
|
end
|
61
71
|
|
62
72
|
it "should get url with :thumb" do
|