ruby on rails - Setup for an uploader (carrierwave) -
i have image uploader in place following tutorial using gems carrierwave , fog. add additional uploader struggling.
i have generated uploader (rails generate uploader name
). in model file have mounted uploader right column (mount_uploader :column_name, nameuploader
). in uploader have set def extension_white_list
, store_dir
. included (since in tutorial did same):
if rails.env.production? storage :fog else storage :file end
now i'm stuck don't know set specifications fog. is, specify amazon bucket should upload to. in carrier_wave initializer had code below. code specifies upload uploader had implemented. these specifications different new uploader. where/how should include these specs new uploader?
if rails.env.production? carrierwave.configure |config| config.fog_credentials = { :provider => 'aws', :aws_access_key_id => env['s3_access_key'], :aws_secret_access_key => env['s3_secret_key'], :region => env['aws_region'] } config.fog_directory = env['s3_bucket'] end end
by looking @ this wiki page seems possible override config each uploader
class avataruploader < carrierwave::uploader::base # choose kind of storage use uploader: storage :fog # define uploader specific configurations in initializer # override global configuration def initialize(*) super self.fog_credentials = { :provider => 'aws', # required :aws_access_key_id => 'yourawskeyid', # required :aws_secret_access_key => 'yourawssecret', # required } self.fog_directory = "yourbucket" end end
Comments
Post a Comment