Paper clip rails miscellaneous file problems
I am using paperclip to upload files, image processing is easy, but how can I handle images (png, jpg) and swf in the same upload, even in pdf files when I have to create different styles of images but not other formats.
+2
kristian nissen
source
to share
3 answers
While 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 called asset
. Change if necessary.
+3
devth
source
to share
Here you go, a bit of a ragged post, but the idea works quietly. http://www.mrkris.com/2009/09/15/paperclip-before_process-for-your-habitual-pornographic-needs/
0
Elad meidar
source
to share
Working code
before_post_process :is_image?
def is_image?
!(self.pc.content_type =~ /^image/).nil?
end
Where "pc" is your attachment name
0
Sidhannowe
source
to share