Support for both image and non-image files?

127 views
Skip to first unread message

Daniel Eriksson

unread,
Jan 3, 2012, 10:23:30 AM1/3/12
to Paperclip Plugin
How can I configure Paperclip to work with both image and non-image
files? It seems that if you set the "styles" option it assumes that
all files are images.

I have a model configured with:
has_attached_file :file, :styles => { :thumb => "100x100" },

When I for example try to upload a csv file it tries to determine the
image dimensions of it and fails with:
File /var/folders/9v/397k1fns3m768s9ywf263v_c0000gn/T/
stream10453-0.csv is not recognized by the 'identify' command.


mikej

unread,
Jan 13, 2012, 11:29:14 AM1/13/12
to papercli...@googlegroups.com
I believe you just need to remove the :styles option.

Mike

--
Individuals over processes. Interactions over tools.

Agile Rails training from thoughtbot, the makers of Paperclip, Clearance, Shoulda, & Factory Girl:
http://thoughtbot.com/services/training

The Paperclip group:
http://groups.google.com/group/paperclip-plugin

To post to this group, send email to
papercli...@googlegroups.com

To unsubscribe from this group, send email to
paperclip-plug...@googlegroups.com

Yuval

unread,
Feb 16, 2012, 12:56:30 PM2/16/12
to Paperclip Plugin
before_post_process :conditionally_resize

def conditionally_resize
return false unless upload_content_type =~ your_image_regex
end

Honestly, considering the broad need for this functionality I'm
surprised its not built in.

On Jan 3, 8:23 am, Daniel Eriksson <eriks...@it.auktionskompaniet.com>
wrote:
Reply all
Reply to author
Forward
0 new messages