Reputation: 406
I setup paperclip to work with my PDF attachments. Currently, when I go to the console and I search Model.certificate.url, I get a URL as such:
//bucketname-staging.s3.amazonaws.com/policies/certificates/000/001/163/original/certificate_bc4525d9-8d41-4635-8f26-ba24b0b69037.pdf?1493755437
However, I am not able to access this link as there is no HTTP/HTTPS beginning associated with this. If I use Model.certificate.expiring_url, I get the full link with HTTP/HTTPs.
Why is this?
Here are my options in production.rb
config.paperclip_defaults = {
url: ":s3_domain_url",
path: "/:class/:attachment/:id_partition/:style/:filename",
storage: :s3,
s3_credentials: {
bucket: ENV.fetch('S3_BUCKET_NAME'),
access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
s3_region: ENV.fetch('AWS_REGION'),
}
}
Upvotes: 0
Views: 44
Reputation: 5742
Your configuration should include the s3_protocol
option, mentioned in the docs:
config.paperclip_defaults = {
url: ":s3_domain_url",
path: "/:class/:attachment/:id_partition/:style/:filename",
storage: :s3,
s3_protocol: 'http',
s3_credentials: {
bucket: ENV.fetch('S3_BUCKET_NAME'),
access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
s3_region: ENV.fetch('AWS_REGION'),
}
}
Upvotes: 1