ruby on rails - Paperclip - Upload to different S3 URLs from Different models -


i had model used paperclip , stored s3.

in paperclip.rb

bucket_name = (rails.env != 'production') ? "mcds_staging_fulltext" : 'mcds_fulltext' paperclip::attachment.default_options.merge!({   storage: :s3,   s3_credentials: {    bucket: bucket_name }, url: "#{customer}/static_cover_images/:style/:basename.:extension", path: "#{customer}/static_cover_images/:style/:basename.:extension" }) 

model1.rb

  has_attached_file :cover_image, styles: { :original => ["100%"], :thumbnail => ["100*100", :png] }   validates_attachment_content_type :cover_image, content_type: /\aimage\/.*\z/, message: 'invalid content type. please upload jpg/jpeg/png/gif'   validates_attachment_size :cover_image, :in => 0.megabytes..5.megabytes, :message => 'must smaller 5 mb' 

this works poperly , store images in s3 in correct location.

now have model need upload paperclip attachment different s3 location.

in model2.rb

 has_attached_file :xslt  paperclip::attachment.default_options.merge!({url: "#{customer}/xslts/:style/:basename.:extension"})  validates_attachment_content_type :xslt, content_type: "application/xslt+xml", message: 'invalid content type. please upload jpg/jpeg/png/gif'  validates_attachment_size :xslt, :in => 0.megabytes..5.megabytes, :message => 'must smaller 5 mb' 

but attachment still stores model1 s3 , not in url specified in model2.

what doing wrong?

i removed paper_clip.rb file , added paper_clip configurations in therespective models.

model1:

has_attached_file :file1, storage: :s3, s3_credentials: {  bucket: bucket_name }, url: "#{customer}/cover_images/:style/:basename.:extension", path: "#{customer}/cover_images/:style/:basename.:extension" 

model2:

has_attached_file :file2, storage: :s3, s3_credentials: {  bucket: bucket_name }, url: "#{customer}/file2_folder/:style/:basename.:extension", path: "#{customer}/file2_folder/:style/:basename.:extension" 

this stores theattachment correctly in differen s3 folders.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -