2

I have a ruby on rails 4 app that uses ajax file uploading. Is there a way I can prevent the user from uploading password-protected or corrupt / malformed PDF files?

UPDATE: Just saw this post on checking if a PDF is corrupt using pdf-reader gem and it might work but I still need help detecting a locked pdf file: Fastest way to check that a PDF is corrupted (Or just missing EOF) in Ruby?


In case it matters, I'm using: rails 4.2.5, ruby 2.1.6, remotipart 1.2.1

Community
  • 1
  • 1
echo
  • 900
  • 1
  • 9
  • 17
  • Do you have a PDF library for Ruby that can read and verify the PDF is valid? If so, use that. If not, find one, like [pdf-reader](https://github.com/yob/pdf-reader). – tadman Apr 15 '16 at 18:30
  • @tadman thank you. I just read about pdf-reader on another post. I'll try it out. – echo Apr 15 '16 at 18:32

0 Answers0