Class: Cloudpt::API::File

Inherits:
Object
  • Object
show all
Includes:
Fileops
Defined in:
lib/cloudpt-api/objects/file.rb

Instance Attribute Summary

Attributes inherited from Object

#client

Instance Method Summary collapse

Methods included from Fileops

#copy, #destroy, #move, #path

Methods inherited from Object

convert, #deep_update, init, resolve_class

Instance Method Details

#copy_ref(options = {}) ⇒ Object



32
33
34
35
# File 'lib/cloudpt-api/objects/file.rb', line 32

def copy_ref(options = {})
  response = client.raw.copy_ref({ :path => self.path }.merge(options))
  Cloudpt::API::Object.init(response, client)
end

#direct_url(options = {}) ⇒ Object



23
24
25
26
# File 'lib/cloudpt-api/objects/file.rb', line 23

def direct_url(options = {})
  response = client.raw.media({ :path => self.path }.merge(options))
  Cloudpt::API::Object.init(response, client)
end

#downloadObject

alias_method :old_path, :path def path

if Cloudpt::API::Config.mode == 'sandbox'
  Cloudpt::API::Util.strip_slash(self['path'].sub(/^\/([^\/]+)?/, ''))
else
  old_path
end

end



47
48
49
# File 'lib/cloudpt-api/objects/file.rb', line 47

def download
  client.download(self.path)
end

#restore(rev, options = {}) ⇒ Object



13
14
15
16
# File 'lib/cloudpt-api/objects/file.rb', line 13

def restore(rev, options = {})
  response = client.raw.restore({ :rev => rev, :path => self.path }.merge(options))
  self.update response
end

#revisions(options = {}) ⇒ Object



8
9
10
11
# File 'lib/cloudpt-api/objects/file.rb', line 8

def revisions(options = {})
  response = client.raw.revisions({ :path => self.path }.merge(options))
  Cloudpt::API::Object.convert(response, client)
end

#share_url(options = {}) ⇒ Object



18
19
20
21
# File 'lib/cloudpt-api/objects/file.rb', line 18

def share_url(options = {})
  response = client.raw.shares({ :path => self.path }.merge(options))
  Cloudpt::API::Object.init(response, client)
end

#thumbnail(options = {}) ⇒ Object



28
29
30
# File 'lib/cloudpt-api/objects/file.rb', line 28

def thumbnail(options = {})
  client.raw.thumbnails({ :path => self.path }.merge(options))
end