在我的Rails應用程序,我想允許用戶通過Carrierwave無論是上傳圖片還是非圖像文件。目前,Carrierwave正在精細地處理和處理圖像文件,但不幸的是,它完全丟棄了非圖像文件。有沒有一種單一的Carrierwave上傳器處理圖像和非圖像文件的簡潔方法?隨着Carrierwave和Rails 3是可以很好地管理與同一上傳圖像和非圖像文件?
我會包括我的低於目前上傳:
class AssetUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
version :thumb do
process :resize_to_fill => [300, 300]
end
version :icon do
process :resize_to_fill => [48, 48]
end
def extension_white_list
%w(jpg jpeg gif png pdf doc xls docx xlsx ppt)
end
end
我沒有用過CarrierWave寶石,但與回形針這是非常微不足道的。查看CW的自述文件,使用它看起來比使用Paperclip更復雜。只要我的$ 0.02 – Yardboy 2011-05-12 02:45:34
你說得對。我實際上最終轉回回形針,嘿。 – jklina 2011-05-12 13:48:00