I have just recently setup my rails 3.2 app to use the carrierwave gem and upload files to S3. What I don't see is the ability to use a different bucket per uploader. Does anyone know if this is a possiblity?
The bucket is specified via the fog_directory config. This configuration option is defined on the uploader and could simply be overwritten with your own method.
Just add the following to your uploader:
def fog_directory
# your bucket name here
end
The carrierwave wiki explains how to use a separate s3 bucket for each uploader :
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
Multiple buckets is not currently supported by CarrierWave. You can separate files between uploaders by adding prefixes (folders) to the store_dir
. Pull requests are welcome though if this is something you'd like to work on!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.