Serving files over HTTPS dynamically based on request.ssl? with Attachment_fu
Posted
by Marston A.
on Stack Overflow
See other posts from Stack Overflow
or by Marston A.
Published on 2009-09-07T10:35:50Z
Indexed on
2010/04/27
4:43 UTC
Read the original article
Hit count: 327
I see there is a :user_ssl
option in attachment_fu
which checks the amazon_s3.yml file in order to serve files via https://
In the s3_backend.rb you have this method:
def self.protocol
@protocol ||= s3_config[:use_ssl] ? 'https://' : 'http://'
end
But this then makes it serve ALL s3 attachments with SSL. I'd like to make it dynamic depending if the current request was made with https:// i.e:
if request.ssl?
@protocol = "https://"
else
@protocol = "http://"
end
How can I make it work in this way? I've tried modifying the method and then get the NameError: undefined local variable or method `request' for Technoweenie::AttachmentFu::Backends::S3Backend:Module error
© Stack Overflow or respective owner