Class: Ey::Core::Client::ApplicationArchive
- Extended by:
- Associations
- Defined in:
- lib/ey-core/models/application_archive.rb
Instance Method Summary collapse
- #download ⇒ Object
-
#mime_type ⇒ Object
FIXME: hard coded in core, not exposed via api.
- #save! ⇒ Object
- #upload(options) ⇒ Object
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
#download ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/ey-core/models/application_archive.rb', line 58 def download requires :url params = { "url" => self.url, } self.connection.download_file(params) end |
#mime_type ⇒ Object
FIXME: hard coded in core, not exposed via api
15 16 17 |
# File 'lib/ey-core/models/application_archive.rb', line 15 def mime_type "text/plain" end |
#save! ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ey-core/models/application_archive.rb', line 19 def save! if new_record? requires :filename params = { "url" => self.collection.url, "application" => self.application_id, "application_archive" => { "filename" => filename, "sha256" => sha256, }, } merge_attributes(self.connection.create_application_archive(params).body["application_archive"]) else params = { "id" => id, "application" => self.application_id, "application_archive" => { "upload_successful" => upload_successful, } } merge_attributes(self.connection.update_application_archive(params).body["application_archive"]) end end |
#upload(options) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ey-core/models/application_archive.rb', line 43 def upload() requires :upload_url params = { "body" => [:body] || File.read([:file]), "mime_type" => self.mime_type, "upload_url" => self.upload_url, } self.connection.upload_file(params) self.upload_successful = true self.save end |