Class: Fog::Storage::HP::SharedFile

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/hp/models/storage/shared_file.rb

Instance Method Summary collapse

Instance Method Details

#bodyObject



19
20
21
22
23
24
25
# File 'lib/fog/hp/models/storage/shared_file.rb', line 19

def body
  attributes[:body] ||= if last_modified
    collection.get(identity).body
  else
    ''
  end
end

#body=(new_body) ⇒ Object



27
28
29
# File 'lib/fog/hp/models/storage/shared_file.rb', line 27

def body=(new_body)
  attributes[:body] = new_body
end

#destroyObject



31
32
33
34
35
36
37
38
# File 'lib/fog/hp/models/storage/shared_file.rb', line 31

def destroy
  requires :shared_directory, :key
  service.delete_shared_object(self.url)
  true
# throws exception Fog::HP::Errors::Forbidden if insufficient access
rescue Fog::Storage::HP::NotFound
  false
end

#save(options = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fog/hp/models/storage/shared_file.rb', line 44

def save(options = {})
  requires :shared_directory, :key
  options['Content-Type'] = content_type if content_type
  data = service.put_shared_object(shared_directory.url, key, body, options)
  merge_attributes(data.headers)
  self.content_length = Fog::Storage.get_body_size(body)
  true
# throws exception Fog::HP::Errors::Forbidden if insufficient access
rescue Fog::Storage::HP::NotFound
  false
end

#shared_directoryObject



40
41
42
# File 'lib/fog/hp/models/storage/shared_file.rb', line 40

def shared_directory
  @shared_directory
end

#urlObject



15
16
17
# File 'lib/fog/hp/models/storage/shared_file.rb', line 15

def url
  "#{self.collection.shared_directory.url}/#{key}"
end