s3 0.3.10 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/{README.md → README.rdoc} +21 -21
- data/lib/s3/object.rb +2 -1
- data/lib/s3/version.rb +1 -1
- data/test/object_test.rb +9 -0
- metadata +14 -11
data/Gemfile.lock
CHANGED
data/{README.md → README.rdoc}
RENAMED
@@ -1,60 +1,60 @@
|
|
1
|
-
|
1
|
+
= S3
|
2
2
|
|
3
|
-
S3 library provides access to
|
3
|
+
S3 library provides access to {Amazon's Simple Storage Service}[http://aws.amazon.com/s3/].
|
4
4
|
|
5
|
-
It supports both: European and US buckets through the
|
5
|
+
It supports both: European and US buckets through the {REST API}[http://docs.amazonwebservices.com/AmazonS3/latest/API/APIRest.html].
|
6
6
|
|
7
|
-
|
7
|
+
== Installation
|
8
8
|
|
9
9
|
gem install s3
|
10
10
|
|
11
|
-
|
11
|
+
== Usage
|
12
12
|
|
13
|
-
|
13
|
+
=== Initialize the service
|
14
14
|
|
15
15
|
require "s3"
|
16
16
|
service = S3::Service.new(:access_key_id => "...",
|
17
17
|
:secret_access_key => "...")
|
18
18
|
#=> #<S3::Service:...>
|
19
19
|
|
20
|
-
|
20
|
+
=== List buckets
|
21
21
|
|
22
22
|
service.buckets
|
23
23
|
#=> [#<S3::Bucket:first-bucket>,
|
24
24
|
# #<S3::Bucket:second-bucket>]
|
25
25
|
|
26
|
-
|
26
|
+
=== Find bucket
|
27
27
|
|
28
28
|
first_bucket = service.buckets.find("first-bucket")
|
29
29
|
#=> #<S3::Bucket:first-bucket>
|
30
30
|
|
31
|
-
|
31
|
+
=== List objects in a bucket
|
32
32
|
|
33
33
|
first_bucket.objects
|
34
34
|
#=> [#<S3::Object:/first-bucket/lenna.png>,
|
35
35
|
# #<S3::Object:/first-bucket/lenna_mini.png>]
|
36
36
|
|
37
|
-
|
37
|
+
=== Find object in a bucket
|
38
38
|
|
39
39
|
object = first_bucket.objects.find("lenna.png")
|
40
40
|
#=> #<S3::Object:/first-bucket/lenna.png>
|
41
41
|
|
42
|
-
|
42
|
+
=== Access object metadata (cached from find)
|
43
43
|
|
44
44
|
object.content_type
|
45
45
|
#=> "image/png"
|
46
46
|
|
47
|
-
|
47
|
+
=== Access object content (downloads the object)
|
48
48
|
|
49
49
|
object.content
|
50
50
|
#=> "\x89PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00..."
|
51
51
|
|
52
|
-
|
52
|
+
=== Delete an object
|
53
53
|
|
54
54
|
object.destroy
|
55
55
|
#=> true
|
56
56
|
|
57
|
-
|
57
|
+
=== Create an object
|
58
58
|
|
59
59
|
new_object = bucket.objects.build("bender.png")
|
60
60
|
#=> #<S3::Object:/synergy-staging/bender.png>
|
@@ -67,13 +67,13 @@ It supports both: European and US buckets through the [REST API](http://docs.ama
|
|
67
67
|
Please note that new objects are created with "public-read" ACL by
|
68
68
|
default.
|
69
69
|
|
70
|
-
|
70
|
+
== See also
|
71
71
|
|
72
|
-
* [
|
73
|
-
* [
|
74
|
-
*
|
75
|
-
* [
|
72
|
+
* rubygems[http://rubygems.org/gems/s3]
|
73
|
+
* repository[http://github.com/qoobaa/s3]
|
74
|
+
* {issue tracker}[http://github.com/qoobaa/s3/issues]
|
75
|
+
* documentation[http://rubydoc.info/github/qoobaa/s3/master/frames]
|
76
76
|
|
77
|
-
|
77
|
+
== Copyright
|
78
78
|
|
79
|
-
Copyright (c) 2009 Jakub Kuźma, Mirosław Boruta. See [
|
79
|
+
Copyright (c) 2009 Jakub Kuźma, Mirosław Boruta. See LICENSE[http://github.com/qoobaa/s3/raw/master/LICENSE] for details.
|
data/lib/s3/object.rb
CHANGED
@@ -6,7 +6,7 @@ module S3
|
|
6
6
|
extend Forwardable
|
7
7
|
|
8
8
|
attr_accessor :content_type, :content_disposition, :content_encoding, :cache_control
|
9
|
-
attr_reader :last_modified, :etag, :size, :bucket, :key, :acl, :storage_class
|
9
|
+
attr_reader :last_modified, :etag, :size, :bucket, :key, :acl, :storage_class, :metadata
|
10
10
|
attr_writer :content
|
11
11
|
|
12
12
|
def_instance_delegators :bucket, :name, :service, :bucket_request, :vhost?, :host, :path_prefix
|
@@ -235,6 +235,7 @@ module S3
|
|
235
235
|
end
|
236
236
|
|
237
237
|
def parse_headers(response)
|
238
|
+
@metadata = response.to_hash.select { |k, v| k.to_s.start_with?("x-amz-meta") }
|
238
239
|
self.etag = response["etag"] if response.key?("etag")
|
239
240
|
self.content_type = response["content-type"] if response.key?("content-type")
|
240
241
|
self.content_disposition = response["content-disposition"] if response.key?("content-disposition")
|
data/lib/s3/version.rb
CHANGED
data/test/object_test.rb
CHANGED
@@ -22,6 +22,7 @@ class ObjectTest < Test::Unit::TestCase
|
|
22
22
|
@response_binary["content-encoding"] = nil
|
23
23
|
@response_binary["last-modified"] = Time.now.httpdate
|
24
24
|
@response_binary["content-length"] = 20
|
25
|
+
@response_binary["x-amz-meta-test"] = "metadata"
|
25
26
|
|
26
27
|
@xml_body = <<-EOXML
|
27
28
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -132,6 +133,14 @@ class ObjectTest < Test::Unit::TestCase
|
|
132
133
|
assert @object_lena.retrieve
|
133
134
|
end
|
134
135
|
|
136
|
+
test "retrieve headers" do
|
137
|
+
@object_lena.expects(:object_request).twice.with(:head, {}).returns(@response_binary)
|
138
|
+
assert @object_lena.retrieve
|
139
|
+
|
140
|
+
meta = {"x-amz-meta-test" => ["metadata"]}
|
141
|
+
assert_equal meta, @object_lena.retrieve.metadata
|
142
|
+
end
|
143
|
+
|
135
144
|
test "exists" do
|
136
145
|
@object_lena.expects(:retrieve).returns(true)
|
137
146
|
assert @object_lena.exists?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.11
|
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: 2011-12-
|
12
|
+
date: 2011-12-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: proxies
|
16
|
-
requirement: &
|
16
|
+
requirement: &6899940 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *6899940
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: test-unit
|
27
|
-
requirement: &
|
27
|
+
requirement: &6952760 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '2.0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *6952760
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: mocha
|
38
|
-
requirement: &
|
38
|
+
requirement: &6952100 !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: *
|
46
|
+
version_requirements: *6952100
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &6950720 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 1.0.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *6950720
|
58
58
|
description: ! 'S3 library provides access to Amazon''s Simple Storage Service. It
|
59
59
|
supports both: European and US buckets through REST API.'
|
60
60
|
email:
|
@@ -67,7 +67,7 @@ files:
|
|
67
67
|
- Gemfile
|
68
68
|
- Gemfile.lock
|
69
69
|
- LICENSE
|
70
|
-
- README.
|
70
|
+
- README.rdoc
|
71
71
|
- Rakefile
|
72
72
|
- lib/s3.rb
|
73
73
|
- lib/s3/bucket.rb
|
@@ -100,6 +100,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
100
|
- - ! '>='
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
hash: -3173124590106976282
|
103
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
107
|
none: false
|
105
108
|
requirements:
|