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.



332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/s3sync/S3.rb', line 332

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.



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

def calling_format
  @calling_format
end

#expiresObject

Returns the value of attribute expires.



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

def expires
  @expires
end

#expires_inObject

Returns the value of attribute expires_in.



325
326
327
# File 'lib/s3sync/S3.rb', line 325

def expires_in
  @expires_in
end

#portObject (readonly)

Returns the value of attribute port.



327
328
329
# File 'lib/s3sync/S3.rb', line 327

def port
  @port
end

#serverObject (readonly)

Returns the value of attribute server.



326
327
328
# File 'lib/s3sync/S3.rb', line 326

def server
  @server
end

Instance Method Details

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



359
360
361
# File 'lib/s3sync/S3.rb', line 359

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

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



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

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

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



372
373
374
# File 'lib/s3sync/S3.rb', line 372

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

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



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

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

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



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

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

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



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

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

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



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

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

#list_all_my_buckets(headers = {}) ⇒ Object



418
419
420
# File 'lib/s3sync/S3.rb', line 418

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



364
365
366
367
368
369
370
# File 'lib/s3sync/S3.rb', line 364

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.



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

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.



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

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



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

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



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

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