Sha256: fc8e07124a12b9a7ff8baa02957976ebd7007859e25b475aa93e697ee7e6f7e3
Contents?: true
Size: 804 Bytes
Versions: 36
Compression:
Stored size: 804 Bytes
Contents
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
Version data entries
36 entries across 36 versions & 1 rubygems