Reputation: 3907
I'm uploading files to S3 using paperclip
so would like to know if i can set the path something like,
:path => "/advertisements/:username/:filename”
the thing is that :usename
is from other model; i'm uploading files on model_2
and :username
comes from model_1
. How can i set the path to indicate the :username
Sample:
:path => "/advertisements/@model_1.username/:filename”
Any ideas?
Thanks in advance!
Upvotes: 1
Views: 712
Reputation: 7059
Here is nice explanation:
please view the answer.
Rails 4, Paperclip, Amazon S3 Config Amazon Path
Model:
#Image Upload
Paperclip.options[:command_path] = 'C:\RailsInstaller\ImageMagick'
has_attached_file :image,
:styles => { :medium => "x300", :thumb => "x100" },
:default_url => "****",
:storage => :s3,
:bucket => '****',
:s3_credentials => S3_CREDENTIALS,
:url => "/:image/:id/:style/:basename.:extension",
:path => ":image/:id/:style/:basename.:extension"
config/application.rb
# Paperclip (for Amazon) (we use EU servers)
config.paperclip_defaults = {
:storage => :s3,
:s3_host_name => 's3-eu-west-1.amazonaws.com'
}
config/s3.yml
development:
access_key_id: **********
secret_access_key: **************
bucket: ****
production:
access_key_id: ***********
secret_access_key: ***********
bucket: ****
I hope this is what you're looking for :)
Upvotes: 2