Class: Ey::Core::Client::BackupFile

Inherits:
Model
  • Object
show all
Extended by:
Associations
Defined in:
lib/ey-core/models/backup_file.rb

Instance Method Summary collapse

Methods included from Associations

assoc_accessor, assoc_coverage, assoc_reader, assoc_writer, associations, collection_reader

Methods inherited from Model

#destroy, range_parser, #save, #to_s, #update!, #url

Instance Method Details

#downloadObject



43
44
45
46
47
48
49
50
51
# File 'lib/ey-core/models/backup_file.rb', line 43

def download
  requires :download_url

  params = {
    "url" => self.download_url,
  }

  self.connection.download_file(params)
end

#save!Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ey-core/models/backup_file.rb', line 14

def save!
  params = {
    "url"         => self.collection.url,
    "backup_file" => {
      "filename"  => self.filename,
      "mime_type" => self.mime_type,
      "metadata"  => self.,
    },
  }

  if new_record?
    merge_attributes(self.connection.create_backup_file(params).body["backup_file"])
  else raise NotImplementedError # update
  end
end

#upload(options) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ey-core/models/backup_file.rb', line 30

def upload(options)
  requires :upload_url

  params = {
    "body"       => options[:body],
    "file"       => options[:file],
    "mime_type"  => options[:mime_type] || self.mime_type,
    "upload_url" => self.upload_url,
  }

  self.connection.upload_file(params)
end