Determining mime type

0 views
Skip to first unread message

dxm

unread,
Nov 24, 2009, 6:57:11 PM11/24/09
to Paperclip Plugin
The problem I am currently trying to solve is providing users the
ability to upload a number of different types of files.
i.e. when working with a document, they can upload a file to associate
with it. That file could be an image, or a .doc or a pdf (could even
be movies at some point).
So, I am thinking of having a DocumentFiles model which I would then
use paperclip to associate the files with.
The user browses for a file and uploads it to a
document_files_controller (say).

Are there paperclip methods available that would allow me to inspect
the uploaded file and then resize it if it's an image, or if it's a
doc or a pdf then just save it and insert into the DocumentFiles
model?

Does that make sense?

thanks.

Trevor Turk

unread,
Nov 25, 2009, 2:24:30 PM11/25/09
to Paperclip Plugin
On Nov 24, 5:57 pm, dxm <paul.dal...@gmail.com> wrote:
> Are there paperclip methods available that would allow me to inspect
> the uploaded file and then resize it if it's an image, or if it's a
> doc or a pdf then just save it and insert into the DocumentFiles
> model?

I did something like this, so that thumbnails are created for images
but regular files go through unchanged:

http://github.com/trevorturk/static/blob/master/app/models/upload.rb

- Trevor
Reply all
Reply to author
Forward
0 new messages