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
41 42 43 44 45 46 47 48 49 |
# File 'lib/server.rb', line 41 def do_POST(request, response) file_data = request.query["uploaded_image"] random_string = SecureRandom.hex(3) f = File.open("tmp/#{random_string}_image.jpeg", "wb") f.syswrite file_data f.close response.status = FileUtils.compare_file("tmp/#{random_string}_image.jpeg", 'files/image.jpeg') ? 200 : 500 FileUtils.rm_rf("tmp/#{random_string}_image.jpeg") end |