class Server::FilePath
Public Instance Methods
do_POST(request, response)
click to toggle source
# File lib/server.rb, line 42 def do_POST(request, response) file_data = request.query["uploaded_image"] random_string = SecureRandom.hex(3) f = File.open("#{__dir__}/../tmp/#{random_string}_image.jpeg", "wb") f.syswrite file_data f.close response.status = FileUtils.compare_file("#{__dir__}/../tmp/#{random_string}_image.jpeg", "#{__dir__}/../files/image.jpeg") ? 200 : 500 FileUtils.rm_rf("#{__dir__}/../tmp/#{random_string}_image.jpeg") end