Module: S3::CallingFormat

Defined in:
lib/S3.rb,
lib/S3_s3sync_mod.rb

Overview

class for storing calling format constants

Constant Summary collapse

REGULAR =
0
SUBDOMAIN =
1
VANITY =

http://<vanity_domain>/key – vanity_domain resolves to s3.amazonaws.com

2

Class Method Summary collapse

Class Method Details

.build_url_base(protocol, server, port, vpath, bucket, format) ⇒ Object

build the url based on the calling format, and bucket



474
475
476
477
478
479
480
481
482
483
484
485
486
# File 'lib/S3.rb', line 474

def CallingFormat.build_url_base(protocol, server, port, vpath, bucket, format)
  build_url_base = "#{protocol}://"
  if bucket.empty?
    build_url_base << "#{server}:#{port}/${vpath}"
  elsif format == SUBDOMAIN
    build_url_base << "#{bucket}.#{server}:#{port}/${vpath}"
  elsif format == VANITY
    build_url_base << "#{bucket}:#{port}/${vpath}"
  else
    build_url_base << "#{server}:#{port}/${vpath}/#{bucket}"
  end
  return build_url_base 
end

.string_to_format(s) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/S3_s3sync_mod.rb', line 129

def CallingFormat.string_to_format(s)
   case s
   when 'REGULAR'
     return CallingFormat::REGULAR
   when 'SUBDOMAIN'
     return CallingFormat::SUBDOMAIN
   when 'VANITY'
     return CallingFormat::VANITY
   else
     raise "Unsupported calling format #{s}"
   end
end