3

I am making a logging system which keeps track of all the request the web server is getting. How do I check if any of the requests contain any file i.e. any file upload action?

Rajesh Paul
  • 6,793
  • 6
  • 40
  • 57

1 Answers1

4

Maybe check what is your request mime type.

request.content_mime_type.symbol
=> :multipart_form

If that returns :multipart_form you can go through the params values and search for kind of ActionDispatch::Http::UploadedFile.

  • Your way solves the purpose, but going through each params i.e. nested params too, will be so much of an overhead and not feasible in case of high level of nesting in the params. – Rajesh Paul Aug 06 '16 at 06:39