carrierwave-upyun 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ .DS_Store
2
+ *.gem
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "carrierwave-upyun"
6
- s.version = "0.1.3"
6
+ s.version = "0.1.5"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Nowa Zhu"]
9
9
  s.email = ["nowazhu@gmail.com"]
@@ -30,7 +30,9 @@ module CarrierWave
30
30
  @upyun_bucket = options[:upyun_bucket]
31
31
  @connection_options = options[:connection_options] || {}
32
32
  @host = options[:api_host] || 'http://v0.api.upyun.com'
33
- @http = RestClient::Resource.new("#{@host}/#{@upyun_bucket}", @upyun_username, @upyun_password)
33
+ @http = RestClient::Resource.new("#{@host}/#{@upyun_bucket}",
34
+ :user => @upyun_username,
35
+ :password => @upyun_password)
34
36
  end
35
37
 
36
38
  def put(path, payload, headers = {})
@@ -82,7 +84,8 @@ module CarrierWave
82
84
  #
83
85
  def read
84
86
  object = uy_connection.get(@path)
85
- object.net_http_res.read_body
87
+ @headers = object.headers
88
+ object.net_http_res.body
86
89
  end
87
90
 
88
91
  ##
@@ -113,6 +116,14 @@ module CarrierWave
113
116
  nil
114
117
  end
115
118
  end
119
+
120
+ def content_type
121
+ headers[:content_type]
122
+ end
123
+
124
+ def content_type=(new_content_type)
125
+ headers[:content_type] = new_content_type
126
+ end
116
127
 
117
128
  ##
118
129
  # Writes the supplied data into the object on Cloud Files.
@@ -129,7 +140,11 @@ module CarrierWave
129
140
  private
130
141
 
131
142
  def headers
132
- @headers ||= { }
143
+ @headers ||= begin
144
+ uy_connection.get(@path).headers
145
+ rescue Excon::Errors::NotFound # Don't die, just return no headers
146
+ {}
147
+ end
133
148
  end
134
149
 
135
150
  def connection
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-upyun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-02 00:00:00.000000000 Z
12
+ date: 2012-03-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: carrierwave
16
- requirement: &70363930114080 !ruby/object:Gem::Requirement
16
+ requirement: &70201535169360 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.5.7
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70363930114080
24
+ version_requirements: *70201535169360
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rest-client
27
- requirement: &70363930113580 !ruby/object:Gem::Requirement
27
+ requirement: &70201535168860 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.6.7
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70363930113580
35
+ version_requirements: *70201535168860
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70363930113100 !ruby/object:Gem::Requirement
38
+ requirement: &70201535168380 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '2.6'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70363930113100
46
+ version_requirements: *70201535168380
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &70363930112620 !ruby/object:Gem::Requirement
49
+ requirement: &70201535167900 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0.9'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70363930112620
57
+ version_requirements: *70201535167900
58
58
  description: UpYun Storage support for CarrierWave
59
59
  email:
60
60
  - nowazhu@gmail.com
@@ -62,6 +62,7 @@ executables: []
62
62
  extensions: []
63
63
  extra_rdoc_files: []
64
64
  files:
65
+ - .gitignore
65
66
  - .rspec
66
67
  - Gemfile
67
68
  - Gemfile.lock
@@ -70,7 +71,6 @@ files:
70
71
  - lib/carrierwave-upyun.rb
71
72
  - lib/carrierwave/storage/upyun.rb
72
73
  - lib/carrierwave/upyun/configuration.rb
73
- - spec/.DS_Store
74
74
  - spec/foo.gif
75
75
  - spec/foo.jpg
76
76
  - spec/spec_helper.rb
data/spec/.DS_Store DELETED
Binary file