Class: S3::QueryStringAuthGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/S3.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 = , vpath = DEFAULT_VIRTUAL_PATH, format = CallingFormat::REGULAR) ⇒ QueryStringAuthGenerator

Returns a new instance of QueryStringAuthGenerator.



328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/S3.rb', line 328

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

Instance Attribute Details

#calling_formatObject

Returns the value of attribute calling_format.



319
320
321
# File 'lib/S3.rb', line 319

def calling_format
  @calling_format
end

#expiresObject

Returns the value of attribute expires.



320
321
322
# File 'lib/S3.rb', line 320

def expires
  @expires
end

#expires_inObject

Returns the value of attribute expires_in.



321
322
323
# File 'lib/S3.rb', line 321

def expires_in
  @expires_in
end

#portObject (readonly)

Returns the value of attribute port.



323
324
325
# File 'lib/S3.rb', line 323

def port
  @port
end

#serverObject (readonly)

Returns the value of attribute server.



322
323
324
# File 'lib/S3.rb', line 322

def server
  @server
end

Instance Method Details

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



356
357
358
# File 'lib/S3.rb', line 356

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

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



385
386
387
# File 'lib/S3.rb', line 385

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

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



369
370
371
# File 'lib/S3.rb', line 369

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

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



381
382
383
# File 'lib/S3.rb', line 381

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

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



397
398
399
# File 'lib/S3.rb', line 397

def get_acl(bucket, key='', headers={})
  return generate_url('GET', bucket, CGI::escape(key), {'acl' => nil}, headers)
end

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



401
402
403
# File 'lib/S3.rb', line 401

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

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



389
390
391
# File 'lib/S3.rb', line 389

def get_bucket_logging(bucket, headers={})
  return generate_url('GET', bucket, '', {'logging' => nil}, headers)
end

#list_all_my_buckets(headers = {}) ⇒ Object



415
416
417
# File 'lib/S3.rb', line 415

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



361
362
363
364
365
366
367
# File 'lib/S3.rb', line 361

def list_bucket(bucket, options={}, headers={})
  path_args = {}
  options.each { |k, v|
    path_args[k] = v.to_s
  }
  return generate_url('GET', bucket, '', path_args, 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.



376
377
378
379
# File 'lib/S3.rb', line 376

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.



407
408
409
# File 'lib/S3.rb', line 407

def put_acl(bucket, key, acl_xml_doc, headers={})
  return generate_url('PUT', bucket, CGI::escape(key), {'acl' => nil}, headers)
end

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



411
412
413
# File 'lib/S3.rb', line 411

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



393
394
395
# File 'lib/S3.rb', line 393

def put_bucket_logging(bucket, logging_xml_doc, headers={})
  return generate_url('PUT', bucket, '', {'logging' => nil}, headers)
end