chalien
09/30/2021, 1:45 AMinitializer/spree.rb
config.image_attachment_module = 'Spree::Image::PaperclipAttachment'
config.taxon_attachment_module = 'Spree::Taxon::PaperclipAttachment'
then i create a paperclip file with this config
# config/initializers/paperclip.rb
if Rails.application.credentials.dig(:aws, :access_key_id)
attachment_config = {
s3_credentials: {
access_key_id: Rails.application.credentials.dig(:aws, :access_key_id),
secret_access_key: Rails.application.credentials.dig(:aws, :secret_access_key),
bucket: Rails.application.credentials.dig(:aws, :bucket_name),
s3_region: 'us-east-1',
},
storage: :s3,
s3_headers: { "Cache-Control" => "max-age=31557600" },
s3_protocol: "https",
# url: ':s3_alias_url',
# s3_host_alias: '<http://xxxx.cloudfront.net|xxxx.cloudfront.net>',
# bucket: Rails.application.credentials.dig(:aws, :bucket_name),
styles: {
mini: "48x48>",
small: "100x100>",
product: "240x240>",
large: "600x600>"
},
path: "/products/:id/:style/:basename.:extension",
default_url: "/products/:id/:style/:basename.:extension",
default_style: "product",
}
Paperclip::Attachment.default_options.merge!(attachment_config)
end
using this config , I'm receiving an error for authorization
Aws::S3::Errors::AccessDenied (Access Denied):
The issue is that I tried with storage.yml with the same credentials and it works but Paperclip is the only one that let me include the cloudfront url (as far as I know active storage doesn't have the cdn option)
Guys please I need your help to solver this, thanks !! you are the best!! 🙏 🇨🇴kennyadsl
chalien
09/30/2021, 10:49 AMchalien
09/30/2021, 10:53 AM