sndacs 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sndacs (0.2.1)
4
+ sndacs (0.2.2)
5
5
  proxies (~> 0.2.0)
6
6
 
7
7
  GEM
data/README.rdoc CHANGED
@@ -60,6 +60,21 @@ create a bucket to specify location,location can be 'huadong-1' or 'huabei-1' ,d
60
60
 
61
61
  first_bucket.location
62
62
 
63
+ ==== Set bucket policy
64
+
65
+ set bucket public
66
+ bucket_policy = '{"Id":"b32c9be8-2414-d0ed-a19f-e0b3f37db5fc","Statement":[{"Sid":"public-get-object","Effect":"Allow","Action":"storage:GetObject","Resource":"srn:snda:storage:::'+first_bucket.name+'/*"}]}'
67
+ first_bucket.put_bucket_policy(bucket_policy)
68
+
69
+
70
+ ==== Get bucket policy
71
+
72
+ bucket_policy = first_bucket.get_bucket_policy
73
+
74
+ ==== Delete bucket policy
75
+
76
+ first_bucket.delete_bucket_policy
77
+
63
78
  === List objects in a bucket
64
79
 
65
80
  first_bucket.objects
data/lib/sndacs/object.rb CHANGED
@@ -100,9 +100,11 @@ module Sndacs
100
100
  end
101
101
 
102
102
  # Returns Object's URL using protocol specified in service,
103
+ # Return url public reachable when the object is public accessible and public_accessible is true
104
+ # public_accessible given.Default to false
103
105
  # e.g. <tt>http://storage.grandcloud.cn/bucket/key/file.extension</tt>
104
- def url
105
- URI.escape("#{protocol}#{host}/#{path_prefix}#{key}")
106
+ def url(public_accessible = false)
107
+ URI.escape("#{protocol}#{host(public_accessible)}/#{path_prefix}#{key}")
106
108
  end
107
109
 
108
110
  # Returns Object's CNAME URL (without <tt>storage.grandcloud.cn</tt>
@@ -152,28 +154,20 @@ module Sndacs
152
154
 
153
155
  headers = {}
154
156
 
155
- headers[:x_snda_acl] = options[:acl] || acl || "public-read"
157
+ #headers[:x_snda_acl] = options[:acl] || acl || "public-read"
156
158
  headers[:content_type] = options[:content_type] || content_type || "application/octet-stream"
157
159
  headers[:content_encoding] = options[:content_encoding] if options[:content_encoding]
158
160
  headers[:content_disposition] = options[:content_disposition] if options[:content_disposition]
159
161
  headers[:cache_control] = options[:cache_control] if options[:cache_control]
160
- headers[:x_snda_copy_source] = full_key
162
+ headers[:x_snda_copy_source] = [bucket,key].join("/")
161
163
  headers[:x_snda_metadata_directive] = options[:replace] == false ? "COPY" : "REPLACE"
162
164
  headers[:x_snda_copy_source_if_match] = options[:if_match] if options[:if_match]
163
165
  headers[:x_snda_copy_source_if_none_match] = options[:if_none_match] if options[:if_none_match]
164
166
  headers[:x_snda_copy_source_if_unmodified_since] = options[:if_modified_since] if options[:if_modified_since]
165
167
  headers[:x_snda_copy_source_if_modified_since] = options[:if_unmodified_since] if options[:if_unmodified_since]
166
-
167
- response = bucket.send(:bucket_request, :put, :path => key, :headers => headers)
168
- object_attributes = parse_copy_object_result(response.body)
169
-
170
- object = Object.send(:new, bucket, object_attributes.merge(:key => key, :size => size))
171
- object.acl = response["x-snda-acl"]
172
- object.content_type = response["content-type"]
173
- object.content_encoding = response["content-encoding"]
174
- object.content_disposition = response["content-disposition"]
175
- object.cache_control = response["cache-control"]
176
- object
168
+
169
+ response = object_request(:put,:headers => headers)
170
+ response.body
177
171
  end
178
172
 
179
173
  def get_object(options = {})
@@ -1,3 +1,3 @@
1
1
  module Sndacs
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
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: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
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-09-02 00:00:00 Z
18
+ date: 2012-09-04 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: proxies