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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 387db2e8862191a027f5d4dd99d1df9bdfd4b77b
4
- data.tar.gz: 69404451e625d3703a0f4918bce885e2ad2519c2
3
+ metadata.gz: 552fc80ab3151b427003443f8494970253c87db4
4
+ data.tar.gz: 15d4f27db9d2173cda033098646ad82c21a29b20
5
5
  SHA512:
6
- metadata.gz: ee77d72ac9f0f7c3c09181cf2a745bd151d4d899c6215efb95944203aa7123d8adaf40932a7ffd8364c335c6cb76ee19b0c49b55b849e7043c4f8cc9e5edfc56
7
- data.tar.gz: b6ac51e377646fe0f63a7217654f564192fc47507f75ff9569d6bba532eb88b676711c23766b701911d1df9af4a1c687ca3735e86f641c1148182eb1190aa5cd
6
+ metadata.gz: 86801d09e20af64fc5574ae94db229e806dbb2bbc63067c2c2e6a0ad9046abf1f2b361014f854ad59cb5c3a0fcd239caeb7f3fdab9d6d57b7b6bf5f77c2d0bbd
7
+ data.tar.gz: 7a71ecb5d1d1c1428cd00d37b9f04dd05b45a5bd6e9cd7210ce20a827bf11a945683f227d640af02ff4646708a9062b0fa02998762e90cd25a03ef7001765b6d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.5.1
2
+
3
+ - 修正 Aliyun 内部网络上传的支持;(#36)
4
+
1
5
  ## 0.5.0
2
6
 
3
7
  - 增加 Aliyun OSS 图片处理参数的支持,允许 url 传入 `:thumb` 以生成缩略图 URL;
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- carrierwave-aliyun (0.5.0)
4
+ carrierwave-aliyun (0.5.1)
5
5
  aliyun-oss-sdk (>= 0.1.6)
6
6
  carrierwave (>= 0.5.7)
7
7
 
@@ -1,5 +1,5 @@
1
1
  module CarrierWave
2
2
  module Aliyun
3
- VERSION = '0.5.0'
3
+ VERSION = '0.5.1'
4
4
  end
5
5
  end
@@ -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
- # TODO: 实现根据 config.aliyun_internal 来使用内部 host 上传
129
- host = "oss-#{@aliyun_area}.aliyuncs.com"
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 => "cn-hangzhou",
12
- :aliyun_internal => true,
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-cn-beijing.aliyuncs.com/bar/foo.jpg"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-aliyun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee