carrierwave-aliyun-oss 0.4.4 → 0.4.5

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: 1f20e0cea2396c58f7841b1800d5b9bc4634247d
4
- data.tar.gz: 67ff4a2898972cf36a4902fc28315d99b17bd60a
3
+ metadata.gz: 1e944bbf10b763ffcef990f1300a43fa4a0a3675
4
+ data.tar.gz: bb657e7782d233b03610a74a48fdc2187a94d9ba
5
5
  SHA512:
6
- metadata.gz: d30960df8a43f48ecc3bcb8adc349cbcea72f26f5d61a44b4eb38a895495bc09a5f2369ff7d7756ed3f978b43be9a21a518d565ade4b3cd8521db3896360c614
7
- data.tar.gz: b24119fb93e151a72f3c1ee31138b712d33bf1108193b739f9f85946a70165ba69eb81318825fcc1d2921a792287f64fb348b445f5849df855d5a0cc5c77c2a0
6
+ metadata.gz: 1e91ba61740efdb211001e24679ea84b68518f347ae61eaa571fc6d3928c7ec9ab0cc9779a1df2d1672f1db9613de720039d5dac1497204d06be43726d2897c9
7
+ data.tar.gz: 2efb5ec1f6c01193405d7e53f8371d08a15c43cd23ceb491c2a7e09fa0511e1b380931f542091b2755f78387430930f1730e4c45faf961391902decba66c5e8f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- carrierwave-aliyun (0.4.4)
4
+ carrierwave-aliyun-oss (0.4.4)
5
5
  aliyun-sdk (>= 0.4.0)
6
6
  carrierwave (>= 0.5.7)
7
7
 
@@ -144,7 +144,7 @@ PLATFORMS
144
144
  ruby
145
145
 
146
146
  DEPENDENCIES
147
- carrierwave-aliyun!
147
+ carrierwave-aliyun-oss!
148
148
  mini_magick
149
149
  rails (= 4.2.0)
150
150
  rake
data/README.md CHANGED
@@ -11,7 +11,7 @@ This gem adds support for [Aliyun OSS](http://oss.aliyun.com) to [CarrierWave](h
11
11
  ## Using Bundler
12
12
 
13
13
  ```ruby
14
- gem 'carrierwave-aliyun'
14
+ gem 'carrierwave-aliyun-oss', require: 'carrierwave-aliyun'
15
15
  ```
16
16
 
17
17
  ## Configuration
@@ -1,5 +1,5 @@
1
1
  module CarrierWave
2
2
  module Aliyun
3
- VERSION = '0.4.4'
3
+ VERSION = '0.4.5'
4
4
  end
5
5
  end
@@ -45,11 +45,10 @@ module CarrierWave
45
45
  # 读取文件
46
46
  # params:
47
47
  # - path - remote 存储路径
48
- # returns:
49
- # file data
50
- def get(path)
48
+ # returns: Aliyun::OSS::Object
49
+ def get(path, &block)
51
50
  path.sub!(PATH_PREFIX, '')
52
- private_client.get_object(path){ |content| content }
51
+ private_client.get_object(path){ |content| yield content if block_given?}
53
52
  end
54
53
 
55
54
  # 删除 Remote 的文件
@@ -158,9 +157,10 @@ module CarrierWave
158
157
  # [String] contents of the file
159
158
  #
160
159
  def read
161
- object = oss_connection.get(@path)
160
+ body = ""
161
+ object = oss_connection.get(@path){|chunk| body = chunk}
162
162
  @headers = object.headers
163
- object.body
163
+ body
164
164
  end
165
165
 
166
166
  ##
data/spec/aliyun_spec.rb CHANGED
@@ -23,6 +23,14 @@ describe "Aliyun" do
23
23
  expect(res.code).to eq "200"
24
24
  end
25
25
 
26
+ it "should get" do
27
+ content = ""
28
+ obj = @connection.get("a/a.jpg"){|chunk| content = chunk}
29
+ expect(content.length).to be >0
30
+ expect(obj.size).to be >0
31
+ expect(obj.headers).not_to be_empty
32
+ end
33
+
26
34
  it "should put with / prefix" do
27
35
  url = @connection.put("/a/a.jpg",load_file("foo.jpg"))
28
36
  res = Net::HTTP.get_response(URI.parse(url))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-aliyun-oss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-03 00:00:00.000000000 Z
11
+ date: 2016-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: carrierwave