0

I am currently using carrierwave, and i am wondering if the following his possible. If so how!. Thanks in advance

I have a user and wants to upload an avatar then the following folder would be created

public/image/avatar/customer.id/image01/small
public/image/avatar/customer.id/image01/normal
public/image/avatar/customer.id/image01/big

public/image/avatar/customer.id/image02/small
public/image/avatar/customer.id/image02/normal
public/image/avatar/customer.id/image02/big

Basically, I do not want to overide the previous image has i want to keep them, but create a folder for the newest picture to have it there. Also want the customer id has a path.

Thanks. PS: if its possible, please provide a tutorial or somesort, if not possible would paperclip allow it? Thanks i can't seem to find anything about it.

4

1 回答 1

0

上传者/image_uploader.rb

class ImageUploader < CarrierWave::Uploader::Base

# Include RMagick or MiniMagick support:
include CarrierWave::RMagick
# include CarrierWave::MiniMagick

# Choose what kind of storage to use for this uploader:
storage :file

# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
  def store_dir
    "public/image/avatar/#{current_user.id}"
  end

  version :small do

  end

  version :normal do

  end

  version :big do

  end

end

您的图像上传器应该看起来像这样。

于 2012-08-14T12:50:47.247 回答