class Optidash::Request::Upload

Responsible for handling Upload requests

Public Class Methods

new(key, upload_path, proxy = nil) click to toggle source
Calls superclass method Optidash::Request::Base::new
# File lib/optidash/request.rb, line 108
def initialize(key, upload_path, proxy = nil)
    @type = :upload
    @upload_path = upload_path
    super(key, proxy)
end

Public Instance Methods

perform(binary: false, save_path: nil) click to toggle source
Calls superclass method Optidash::Request::Base#perform
# File lib/optidash/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() click to toggle source

Returns upload request data. Multipart containing uploaded file and operations performed on it

# File lib/optidash/request.rb, line 126
def request_data
    {
        file: File.new(@upload_path, "rb"),
        data: @data.to_json
    }
end