kristian nissen
kristian nissen

Reputation: 2907

rails paperclip different file types problem

I'm using paperclip for uploading files, handling images is easy, but how can I handle images (png, jpg) and swf in the same upload, even pdf files, when I have to create different styles of the images but not the other formats.

Upvotes: 2

Views: 2031

Answers (3)

Sidhannowe
Sidhannowe

Reputation: 475

Working code is

before_post_process :is_image?
def is_image?
  !(self.pc.content_type =~ /^image/).nil?
end

Where "pc" is your attachment name

Upvotes: 0

devth
devth

Reputation: 2750

Although the accepted answer is dead, it looks like the solution is:

  before_post_process :is_image?
  def is_image?
    !(asset_content_type =~ /^image/).nil?
  end

Assuming your attachment is named asset. Modify as necessary.

Upvotes: 3

Elad Meidar
Elad Meidar

Reputation: 186

Here you go, a bit of ragged post but the idea is working quiet well http://www.mrkris.com/2009/09/15/paperclip-before_process-for-your-habitual-pornographic-needs/

Upvotes: 0

Related Questions