Class: S3::QueryStringAuthGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/s3-ruby.rb

Overview

This interface mirrors the AWSAuthConnection class above, but instead of performing the operations, this class simply returns a url that can be used to perform the operation with the query string authentication parameters set.

Constant Summary collapse

DEFAULT_EXPIRES_IN =

by default, expire in 1 minute

60

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aws_access_key_id, aws_secret_access_key, is_secure = true, server = DEFAULT_HOST, port = ) ⇒ QueryStringAuthGenerator

Returns a new instance of QueryStringAuthGenerator.


307
308
309
310
311
312
313
314
315
# File 'lib/s3-ruby.rb', line 307

def initialize(aws_access_key_id, aws_secret_access_key, is_secure=true, server=DEFAULT_HOST, port=PORTS_BY_SECURITY[is_secure])
  @aws_access_key_id = aws_access_key_id
  @aws_secret_access_key = aws_secret_access_key
  @protocol = is_secure ? 'https' : 'http'
  @server = server
  @port = port
  # by default expire
  @expires_in = DEFAULT_EXPIRES_IN
end

Instance Attribute Details

#expiresObject

Returns the value of attribute expires.


302
303
304
# File 'lib/s3-ruby.rb', line 302

def expires
  @expires
end

#expires_inObject

Returns the value of attribute expires_in.


302
303
304
# File 'lib/s3-ruby.rb', line 302

def expires_in
  @expires_in
end

#portObject (readonly)

Returns the value of attribute port.


302
303
304
# File 'lib/s3-ruby.rb', line 302

def port
  @port
end

#serverObject (readonly)

Returns the value of attribute server.


302
303
304
# File 'lib/s3-ruby.rb', line 302

def server
  @server
end

Instance Method Details

#create_bucket(bucket, headers = {}) ⇒ Object


331
332
333
# File 'lib/s3-ruby.rb', line 331

def create_bucket(bucket, headers={})
  return generate_url('PUT', bucket, headers)
end

#delete(bucket, key, headers = {}) ⇒ Object


361
362
363
# File 'lib/s3-ruby.rb', line 361

def delete(bucket, key, headers={})
  return generate_url('DELETE',  "#{bucket}/#{CGI::escape key}", headers)
end

#delete_bucket(bucket, headers = {}) ⇒ Object


345
346
347
# File 'lib/s3-ruby.rb', line 345

def delete_bucket(bucket, headers={})
  return generate_url('DELETE', bucket, headers)
end

#get(bucket, key, headers = {}) ⇒ Object


357
358
359
# File 'lib/s3-ruby.rb', line 357

def get(bucket, key, headers={})
  return generate_url('GET',  "#{bucket}/#{CGI::escape key}", headers)
end

#get_acl(bucket, key = '', headers = {}) ⇒ Object


373
374
375
# File 'lib/s3-ruby.rb', line 373

def get_acl(bucket, key='', headers={})
  return generate_url('GET', "#{bucket}/#{CGI::escape key}?acl", headers)
end

#get_bucket_acl(bucket, headers = {}) ⇒ Object


377
378
379
# File 'lib/s3-ruby.rb', line 377

def get_bucket_acl(bucket, headers={})
  return get_acl(bucket, '', headers)
end

#get_bucket_logging(bucket, headers = {}) ⇒ Object


365
366
367
# File 'lib/s3-ruby.rb', line 365

def get_bucket_logging(bucket, headers={})
  return generate_url('GET', "#{bucket}?logging", headers)
end

#get_torrent(bucket, key, headers = {}) ⇒ Object


395
396
397
# File 'lib/s3-ruby.rb', line 395

def get_torrent(bucket, key, headers={})
  return generate_url('GET',  "#{bucket}/#{CGI::escape key}?torrent", headers)
end

#list_all_my_buckets(headers = {}) ⇒ Object


391
392
393
# File 'lib/s3-ruby.rb', line 391

def list_all_my_buckets(headers={})
  return generate_url('GET', '', headers)
end

#list_bucket(bucket, options = {}, headers = {}) ⇒ Object

takes options :prefix, :marker, :max_keys, and :delimiter


336
337
338
339
340
341
342
343
# File 'lib/s3-ruby.rb', line 336

def list_bucket(bucket, options={}, headers={})
  path = bucket
  if options.size > 0
    path += '?' + options.map { |k, v| "#{k}=#{CGI::escape v}" }.join('&')
  end

  return generate_url('GET', path, headers)
end

#put(bucket, key, object = nil, headers = {}) ⇒ Object

don’t really care what object data is. it’s just for conformance with the other interface. If this doesn’t work, check tcpdump to see if the client is putting a Content-Type header on the wire.


352
353
354
355
# File 'lib/s3-ruby.rb', line 352

def put(bucket, key, object=nil, headers={})
  object = S3Object.new(object) if not object.instance_of? S3Object
  return generate_url('PUT', "#{bucket}/#{CGI::escape key}", merge_meta(headers, object))
end

#put_acl(bucket, key, acl_xml_doc, headers = {}) ⇒ Object

don’t really care what acl_xml_doc is. again, check the wire for Content-Type if this fails.


383
384
385
# File 'lib/s3-ruby.rb', line 383

def put_acl(bucket, key, acl_xml_doc, headers={})
  return generate_url('PUT', "#{bucket}/#{CGI::escape key}?acl", headers)
end

#put_bucket_acl(bucket, acl_xml_doc, headers = {}) ⇒ Object


387
388
389
# File 'lib/s3-ruby.rb', line 387

def put_bucket_acl(bucket, acl_xml_doc, headers={})
  return put_acl(bucket, '', acl_xml_doc, headers)
end

#put_bucket_logging(bucket, logging_xml_doc, headers = {}) ⇒ Object


369
370
371
# File 'lib/s3-ruby.rb', line 369

def put_bucket_logging(bucket, logging_xml_doc, headers={})
  return generate_url('PUT', "#{bucket}?logging", headers)
end