简体   繁体   中英

Paperclip - Store in Custom Folder in S3

I am new to paperclip. I am able to store in s3. But it is actually storing in 'journals/cover_images/000/000/001/original/download.png'. How do I change the path to custom path.

In paper_clip.rb

Paperclip::Attachment.default_options.merge!({
  # :url => "#{bucket_name}/static_cover_images/#{Customer.first.symbol}/:id/:style/:basename.:extension",
  # :path => ":rails_root/public:url"
  storage: :s3,
  s3_credentials: {
    bucket: bucket_name,
    access_key_id: 'xxxxxxxxxxxxxx',
    secret_access_key: 'yyyyyyyyyyyyyyyyyyyyyyy',
    s3_region: 'mx-east-3'
  },
  key: custom_path

})

How do I change the path to the path mentioned in :url?

In paper_clip.rb file, added these two lines.

        :url => "/journals/static_cover_images/:basename.:extension",
        :path => "/journals/static_cover_images/:basename.:extension"`

This works!.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM