Class: Eyeson::FileUpload
- Inherits:
-
Object
- Object
- Eyeson::FileUpload
- Defined in:
- lib/eyeson/file_upload.rb
Overview
Manages file uploads
Defined Under Namespace
Classes: ValidationFailed
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
Instance Method Summary collapse
-
#initialize(access_key) ⇒ FileUpload
constructor
A new instance of FileUpload.
- #upload_from(url) ⇒ Object
Constructor Details
#initialize(access_key) ⇒ FileUpload
Returns a new instance of FileUpload.
11 12 13 14 |
# File 'lib/eyeson/file_upload.rb', line 11 def initialize(access_key) @access_key = access_key @file = nil end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
9 10 11 |
# File 'lib/eyeson/file_upload.rb', line 9 def file @file end |
Instance Method Details
#upload_from(url) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/eyeson/file_upload.rb', line 16 def upload_from(url) Tempfile.class_eval do attr_accessor :original_filename end url = URI(url) @file = OpenURI.open_uri url @file.original_filename = File.basename url.path upload! end |