2

I am using CentOS. I have paperclip gem newest version. I have read about spoofing and yet problem still persists! I even tried older version 3.5.2 and still getting error. I am doing this on remote server! Dont know if I have to restart apache or something? Heelp!

I, [2014-04-09T18:41:45.251093 #5841]  INFO -- : Command :: file -b --mime-type '/tmp/5b42e9da0503617fea7f216d7860262920140409-5841-k6wzm6'
I, [2014-04-09T18:41:45.257581 #5841]  INFO -- : [paperclip] Content Type Spoof: Filename justdoit.jpeg (["image/jpeg"]), content type discovered from file command: . See documentation to allow this combination.

After adding Options , Now I am getting this:

I, [2014-04-09T21:20:46.797630 #11118]  INFO -- : Started GET "/system/bboys/avatars/000/000/001/medium/Casper_Family_11.jpg?1397064045" for 90.197.101.127 at 2014-04-09 21:20:46 +0400
F, [2014-04-09T21:20:46.799580 #11118] FATAL -- : 
ActionController::RoutingError (No route matches [GET] "/system/bboys/avatars/000/000/001/medium/Casper_Family_11.jpg"):
  vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
user3222947
  • 197
  • 1
  • 2
  • 14
  • Go to your terminal and run `file -b --mime path/to/file/justdoit.jpeg` and share the results. – Kirti Thorat Apr 09 '14 at 15:48
  • Could you make a new question with this new problem please - it keeps it easier for others to find problems and solutions in the future. When you post the new question please your model. –  Apr 09 '14 at 17:31

2 Answers2

3

If you aren't worried about the spoofing check for jpeg/jpg files you can set the Paperclip option:

Paperclip.options[:content_type_mappings] = { jpeg: 'image/jpeg', jpg: 'image/jpeg' }

This will bypass the file -b --mime-type command.

  • where do I set this option? Thank you! In model? – user3222947 Apr 09 '14 at 15:43
  • You can set it anywhere that is read when the application intialises; `config/application.rb`, `config/environments/.rb` if you want to be environment specific. I created `config/initializers/paperclip.rb` for things like this because it's not environment specific and I like to separate out gem configuration from my application. –  Apr 09 '14 at 15:52
  • @ Graeme McLean @ Kirti Thorat I thought it was fixed but now getting new error. I edited my post. – user3222947 Apr 09 '14 at 17:24
1

My problem was that I didnt have installed ImageMagic and it is a requirement for paperclip to work.

Aitor Martin
  • 724
  • 1
  • 11
  • 26