Module: S33r::InBucket

Defined in:
lib/s33r/s3_obj.rb

Instance Method Summary collapse

Instance Method Details

#delete(options = {}) ⇒ Object

Delete the object from S3.



219
220
221
# File 'lib/s33r/s3_obj.rb', line 219

def delete(options={})
  bucket.delete(key, options)
end

#fetch(options = {}) ⇒ Object

Fetch an object’s metadata and content from S3.



203
204
205
206
207
208
209
210
211
# File 'lib/s33r/s3_obj.rb', line 203

def fetch(options={})
  resp = do_get(options)
  
  , amz_meta, data = S3Object.parse_response(resp)
  @amz_meta = amz_meta
  @value = data
  set_properties()
  true  
end

#rename(new_key, options = {}) ⇒ Object Also known as: mv

Change the object’s name on S3.



224
225
226
227
228
229
230
231
232
233
# File 'lib/s33r/s3_obj.rb', line 224

def rename(new_key, options={})
  # Delete the object from S3.
  bucket.delete(key, options)
  
  # Set the new key.
  self.key = new_key
  options[:key] = new_key
  
  save(options)
end

#request_defaultsObject

Send requests using the bucket’s options.



198
199
200
# File 'lib/s33r/s3_obj.rb', line 198

def request_defaults
  bucket.request_defaults.merge(:key => key)
end

#save(options = {}) ⇒ Object

Save an object to S3.



214
215
216
# File 'lib/s33r/s3_obj.rb', line 214

def save(options={})
  bucket.put(self, options)
end