Are there any rails libraries for managing file attachments connected with ActiveRecord?
I know paperclip, but it seems suitable for images primarily. They indeed mention audio and pdf files on the github project page, but there's no further explanation about the usage of different file types. Attributes like :style
would change their meaning if you uploaded an audio file. So different file sizes wouldn't be expressed in a two-dimensional resolution but in terms of bitrates.
Are there any alternatives to paperclip? Or is it possible to not just link imagemagick with paperclip but for example ffmpeg?
The question above contains more than one facette. So I'll try to answer them all one-by-one.
Paperclip::Processor
It is possible to use paperclip for other files than images. You can define custom import actions by subclassing Paperclip::Processor. The following code shows a minimal structure of a custom processor implementation. This can be adapted to any file type with custom
options
.paperclip and ffmpeg
Someone wrote a paperclip processor for video files already. Have a look at the source of paperclip-ffmpeg gem to see how complex processors are written.
Alternatives
Here are some alternatives I found:
Pro and Cons are already discussed here on stackoverflow.
There's no reason you couldn't use Paperclip for other types of files, but if you want an alternative you can't go wrong with CarrierWave.