sndacs 0.1.1 → 0.2.1
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.rdoc +19 -0
- data/lib/sndacs/bucket.rb +26 -0
- data/lib/sndacs/connection.rb +4 -2
- data/lib/sndacs/version.rb +1 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -41,11 +41,25 @@ or use even more flexible config style
|
|
41
41
|
#=> [#<Sndacs::Bucket:first-bucket>,
|
42
42
|
# #<Sndacs::Bucket:second-bucket>]
|
43
43
|
|
44
|
+
=== Create bucket
|
45
|
+
|
46
|
+
create a bucket to default location(huabei-1)
|
47
|
+
new_bucket = service.buckets.build("rubybucketdefault")
|
48
|
+
new_bucket.save
|
49
|
+
|
50
|
+
create a bucket to specify location,location can be 'huadong-1' or 'huabei-1' ,default to huabei-1
|
51
|
+
new_bucket = service.buckets.build("rubybuckethuadong-1")
|
52
|
+
new_bucket.save(:location=>"huadong-1")
|
53
|
+
|
44
54
|
=== Find bucket
|
45
55
|
|
46
56
|
first_bucket = service.buckets.find("first-bucket")
|
47
57
|
#=> #<Sndacs::Bucket:first-bucket>
|
48
58
|
|
59
|
+
=== Get bucket's location
|
60
|
+
|
61
|
+
first_bucket.location
|
62
|
+
|
49
63
|
=== List objects in a bucket
|
50
64
|
|
51
65
|
first_bucket.objects
|
@@ -67,6 +81,11 @@ or use even more flexible config style
|
|
67
81
|
object.content
|
68
82
|
#=> "\x89PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00..."
|
69
83
|
|
84
|
+
=== Get A temporary url to an object
|
85
|
+
|
86
|
+
Get a temporary url to the object that expires on the timestamp given.Defaults to 1hour expire time
|
87
|
+
object.temporary_url( Time.now + 60 )
|
88
|
+
|
70
89
|
=== Delete an object
|
71
90
|
|
72
91
|
object.destroy
|
data/lib/sndacs/bucket.rb
CHANGED
@@ -62,6 +62,32 @@ module Sndacs
|
|
62
62
|
true
|
63
63
|
end
|
64
64
|
|
65
|
+
# Set bucket policy for the given bucket
|
66
|
+
def put_bucket_policy(bucket_policy)
|
67
|
+
if bucket_policy && bucket_policy.is_a?(String) && bucket_policy.strip != ''
|
68
|
+
bucket_request(:put,:body => bucket_policy,:subresource=>"policy")
|
69
|
+
true
|
70
|
+
else
|
71
|
+
false
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Delete the policy of the given bucket
|
76
|
+
# exception if the bucket do not have a bucket policy
|
77
|
+
def delete_bucket_policy()
|
78
|
+
bucket_request(:delete,:subresource=>"policy")
|
79
|
+
true
|
80
|
+
end
|
81
|
+
|
82
|
+
# Get the bucket policy of the given bucket
|
83
|
+
# exception if the bucket do not have a bucket policy
|
84
|
+
def get_bucket_policy()
|
85
|
+
response = bucket_request(:get,:subresource=>"policy")
|
86
|
+
#puts response.body
|
87
|
+
response.body
|
88
|
+
end
|
89
|
+
|
90
|
+
|
65
91
|
# Destroys given bucket. Raises an Sndacs::Error::BucketNotEmpty
|
66
92
|
# exception if the bucket is not empty.
|
67
93
|
# You can destroy non-empty bucket passing true (to force destroy)
|
data/lib/sndacs/connection.rb
CHANGED
@@ -64,11 +64,13 @@ module Sndacs
|
|
64
64
|
body = options.fetch(:body, nil)
|
65
65
|
params = options.fetch(:params, {})
|
66
66
|
headers = options.fetch(:headers, {})
|
67
|
-
|
67
|
+
subresource = options.fetch(:subresource,nil)
|
68
68
|
# Must be done before adding params
|
69
69
|
# Encodes all characters except forward-slash (/) and explicitly legal URL characters
|
70
70
|
path = URI.escape(path, /[^#{URI::REGEXP::PATTERN::UNRESERVED}\/]/)
|
71
|
-
|
71
|
+
if subresource
|
72
|
+
path << "?#{subresource}"
|
73
|
+
end
|
72
74
|
if params
|
73
75
|
params = params.is_a?(String) ? params : self.class.parse_params(params)
|
74
76
|
|
data/lib/sndacs/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sndacs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 2
|
8
9
|
- 1
|
9
|
-
|
10
|
-
version: 0.1.1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- LI Daobing
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-09-02 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: proxies
|