uber-s3 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,10 +9,10 @@ class UberS3
9
9
  req_canonical_resource = "/#{client.bucket}/#{path}".split('?').first
10
10
  req_canonical_amz_headers = ''
11
11
 
12
- headers.keys.select {|k| k =~ /^x-amz-acl/ }.each do |amz_key|
12
+ headers.keys.sort.select {|k| k =~ /^x-amz-/ }.each do |amz_key|
13
13
  req_canonical_amz_headers << amz_key+':'+headers[amz_key]+"\n"
14
14
  end
15
-
15
+
16
16
  canonical_string_to_sign = "#{req_verb}\n"+
17
17
  "#{req_content_md5}\n"+
18
18
  "#{req_content_type}\n"+
@@ -9,7 +9,7 @@ class UberS3
9
9
  include Operation::Object::Meta
10
10
  include Operation::Object::StorageClass
11
11
 
12
- attr_accessor :bucket, :key, :value, :size, :error
12
+ attr_accessor :bucket, :key, :response, :value, :size, :error
13
13
 
14
14
  def initialize(bucket, key, value=nil, options={})
15
15
  self.bucket = bucket
@@ -30,9 +30,24 @@ class UberS3
30
30
  def exists?
31
31
  bucket.connection.head(key).status == 200
32
32
  end
33
+
34
+ def head
35
+ bucket.connection.head(key)
36
+ end
33
37
 
34
38
  def fetch
35
- self.value = bucket.connection.get(key).body
39
+ self.response = bucket.connection.get(key)
40
+ self.value = response.body
41
+
42
+ # Meta..
43
+ self.meta ||= {}
44
+ response.header.keys.sort.select {|k| k =~ /^x-amz-meta-/ }.each do |amz_key|
45
+ # TODO.. value is an array.. meaning a meta attribute can have multiple values
46
+ meta[amz_key.gsub(/^x-amz-meta-/, '')] = response.header[amz_key].first
47
+
48
+ # TODO.. em-http adapters return headers that look like X_AMZ_META_ .. very annoying.
49
+ end
50
+
36
51
  self
37
52
  end
38
53
 
@@ -71,6 +86,11 @@ class UberS3
71
86
  if !storage_class.nil?
72
87
  headers['x-amz-storage-class'] = storage_class.to_s.upcase
73
88
  end
89
+
90
+ # Meta
91
+ if !meta.nil? && !meta.empty?
92
+ meta.each {|k,v| headers["x-amz-meta-#{k}"] = v }
93
+ end
74
94
 
75
95
  # Let's do it
76
96
  response = bucket.connection.put(key, headers, value)
@@ -6,6 +6,7 @@ module UberS3::Operation::Object
6
6
  base.send :include, InstanceMethods
7
7
 
8
8
  base.instance_eval do
9
+ attr_accessor :meta
9
10
  end
10
11
  end
11
12
 
@@ -1,3 +1,3 @@
1
1
  class UberS3
2
- VERSION = '0.1.7'
2
+ VERSION = '0.1.8'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uber-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mime-types
16
- requirement: &70223953646180 !ruby/object:Gem::Requirement
16
+ requirement: &70252802210360 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.17'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70223953646180
24
+ version_requirements: *70252802210360
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: net-http-persistent
27
- requirement: &70223953645120 !ruby/object:Gem::Requirement
27
+ requirement: &70252802209240 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.5'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70223953645120
35
+ version_requirements: *70252802209240
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70223953644560 !ruby/object:Gem::Requirement
38
+ requirement: &70252802208760 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70223953644560
46
+ version_requirements: *70252802208760
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70223953643000 !ruby/object:Gem::Requirement
49
+ requirement: &70252802207340 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 2.7.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70223953643000
57
+ version_requirements: *70252802207340
58
58
  description: A simple & very fast S3 client supporting sync / async HTTP adapters
59
59
  email:
60
60
  - peter@nulayer.com