Class: Pixaven::Request::Upload
Overview
Responsible for handling Upload requests
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(key, upload_path, proxy = nil) ⇒ Upload
constructor
A new instance of Upload.
- #perform(binary: false, save_path: nil) ⇒ Object
-
#request_data ⇒ Object
Returns upload request data.
Constructor Details
#initialize(key, upload_path, proxy = nil) ⇒ Upload
Returns a new instance of Upload.
108 109 110 111 112 |
# File 'lib/pixaven/request.rb', line 108 def initialize(key, upload_path, proxy = nil) @type = :upload @upload_path = upload_path super(key, proxy) end |
Instance Method Details
#perform(binary: false, save_path: nil) ⇒ Object
114 115 116 117 118 119 |
# File 'lib/pixaven/request.rb', line 114 def perform(binary: false, save_path: nil) unless File.exist?(@upload_path) return "Input file #{@upload_path} does not exist", nil, nil end super end |
#request_data ⇒ Object
Returns upload request data. Multipart containing uploaded file and operations performed on it
126 127 128 129 130 131 |
# File 'lib/pixaven/request.rb', line 126 def request_data { file: File.new(@upload_path, "rb"), data: @data.to_json } end |