Class: Fog::Storage::InternetArchive::Directory

Inherits:
Model
  • Object
show all
Extended by:
Fog::Storage::IAAttributes::ClassMethods
Includes:
Fog::Storage::IAAttributes::InstanceMethods
Defined in:
lib/fog/internet_archive/models/storage/directory.rb

Instance Method Summary collapse

Methods included from Fog::Storage::IAAttributes::ClassMethods

ia_metadata_attribute

Methods included from Fog::Storage::IAAttributes::InstanceMethods

#set_metadata_array_headers

Instance Method Details

#aclObject

acl for internet archive is always public-read


24
25
26
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 24

def acl
  'public-read'
end

#acl=(new_acl) ⇒ Object


28
29
30
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 28

def acl=(new_acl)
  'public-read'
end

#destroyObject


33
34
35
36
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 33

def destroy
  Fog::Logger.warning("fog: Internet Archive does not support deleting a Bucket (i.e. Item).  For details see: See http://archive.org/help/abouts3.txt")
  false
end

#filesObject


51
52
53
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 51

def files
  @files ||= Fog::Storage::InternetArchive::Files.new(:directory => self, :service => service)
end

#locationObject


38
39
40
41
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 38

def location
  requires :key
  attributes[:location] || bucket_location || self.service.region
end

#location=(new_location) ⇒ Object


43
44
45
46
47
48
49
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 43

def location=(new_location)
  if INVALID_LOCATIONS.include?(new_location)
    raise ArgumentError, "location must not include any of #{INVALID_LOCATIONS.join(', ')}. See http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketPUT.html"
  else
    merge_attributes(:location => new_location)
  end
end

#payerObject


55
56
57
58
59
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 55

def payer
  requires :key
  data = service.get_request_payment(key)
  data.body['Payer']
end

#payer=(new_payer) ⇒ Object


61
62
63
64
65
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 61

def payer=(new_payer)
  requires :key
  service.put_request_payment(key, new_payer)
  @payer = new_payer
end

#public=(new_public) ⇒ Object


67
68
69
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 67

def public=(new_public)
  'public-read'
end

#public_urlObject


71
72
73
74
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 71

def public_url
  requires :key
  "http://#{Fog::InternetArchive::DOMAIN_NAME}/details/#{key}"
end

#saveObject


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 76

def save
  requires :key

  options = {}

  options['x-archive-ignore-preexisting-bucket'] = ignore_preexisting_bucket if ignore_preexisting_bucket
  options['x-archive-interactive-priority'] = interactive_priority if interactive_priority

  (:collections, options)
  (:subjects, options)

  if location = attributes[:location] || (self.service.region != 'us-east-1' && self.service.region)
    options['LocationConstraint'] = location
  end

  service.put_bucket(key, options)

  true
end