Class: Server::FilePath
- Inherits:
-
WEBrick::HTTPServlet::AbstractServlet
- Object
- WEBrick::HTTPServlet::AbstractServlet
- Server::FilePath
- Defined in:
- lib/server.rb
Instance Method Summary collapse
Instance Method Details
#do_POST(request, response) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# 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 |