I have below configurations:
initializers/paperclip.rb
Paperclip::Attachment.default_options[:path] = ':rails_root/public/system/attachments/:id/:basename:style.:extension'
Paperclip::Attachment.default_options[:use_timestamp] = false
Paperclip::Attachment.default_options[:s3_host_name] = 's3.amazonaws.com'
Paperclip::Attachment.default_options[:s3_region] = 'us-west-2'
Paperclip::HttpUrlProxyAdapter.register
environment.rb
config.paperclip_defaults = {
storage: :s3,
s3_credentials: {
bucket: name,
access_key_id: key,
secret_access_key: key,
s3_region: 'us-west-2',
s3_protocol: :https,
url: ":s3_domain_url"
}
}
Gems Used:
gem 'rails', '~> 5.2.8'
gem 'paperclip', '~> 5.3'
gem 'aws-sdk', '~> 2.3'
The read operation is working fine but getting error(Aws::S3::Errors::PermanentRedirect - The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.:) on uploading the file to bucket.