Class: S3::QueryStringAuthGenerator

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

Returns a new instance of QueryStringAuthGenerator.



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

def initialize(aws_access_key_id, aws_secret_access_key, is_secure=true, 
               server=DEFAULT_HOST, port=PORTS_BY_SECURITY[is_secure], 
               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
  @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.



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

def calling_format
  @calling_format
end

#expiresObject

Returns the value of attribute expires.



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

def expires
  @expires
end

#expires_inObject

Returns the value of attribute expires_in.



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

def expires_in
  @expires_in
end

#portObject (readonly)

Returns the value of attribute port.



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

def port
  @port
end

#serverObject (readonly)

Returns the value of attribute server.



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

def server
  @server
end

Instance Method Details

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



354
355
356
# File 'lib/s3sync/S3.rb', line 354

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

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



383
384
385
# File 'lib/s3sync/S3.rb', line 383

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

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



367
368
369
# File 'lib/s3sync/S3.rb', line 367

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

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



379
380
381
# File 'lib/s3sync/S3.rb', line 379

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

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



395
396
397
# File 'lib/s3sync/S3.rb', line 395

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

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



399
400
401
# File 'lib/s3sync/S3.rb', line 399

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

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



387
388
389
# File 'lib/s3sync/S3.rb', line 387

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

#list_all_my_buckets(headers = {}) ⇒ Object



413
414
415
# File 'lib/s3sync/S3.rb', line 413

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



359
360
361
362
363
364
365
# File 'lib/s3sync/S3.rb', line 359

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.



374
375
376
377
# File 'lib/s3sync/S3.rb', line 374

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.



405
406
407
# File 'lib/s3sync/S3.rb', line 405

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



409
410
411
# File 'lib/s3sync/S3.rb', line 409

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



391
392
393
# File 'lib/s3sync/S3.rb', line 391

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