class HttpFileUpload < Filbunke::Callbacks def on_update(file, local_file_path) begin basename = ::File.basename(file.path).chomp(".json") basename =~ /(.*)_(\d)/ classname = $1 id = $2 upload_path = "/model/update/#{classname}/#{id}" file_contents = ::File.read(local_file_path) uri = "http://#{@config['host']}:#{@config['port']}#{upload_path}" response = ::Typhoeus::Request.post(uri, :body => file_contents) if response.code.to_i != 200 @logger.log "Failed to upload: #{file.path}. Server responded with #{response.code}" end rescue StandardError => e @logger.log(e.message) @logger.log("Failed to upload entry: #{file.path}") @logger.log(e.backtrace.join("\n")) end end end