Should be a pretty simple fix to this question, I think, but I can't seem to get it to work. I have a Rails 4 app, a User model with a photograph
attribute setup with Paperclip, and I have it linked to S3.
Here's the User model:
has_attached_file :photograph,
:styles => { :medium => "300x300>", :thumb => "100x100>" },
:storage => :s3,
:bucket => " my-bucket-name ",
:default_url => '/images/:attachment/missing_:style.png',
:s3_credentials => S3_CREDENTIALS
The image gets added to my S3 bucket just fine, but when I try to render the picture with <%= image_tag @user.photograph.url %>
, it doesn't show up. Upon further inspection, the image URL is:
http://s3.amazonaws.com/my-bucket-name/users/photographs/000/000/001/original/20121103_132556.jpg?1388619625
If I follow this URL in a browser, I see an XML file as follows:
<Error>
<Code>PermanentRedirect</Code>
<Message>
The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
</Message>
<RequestId> ... </RequestId>
<Bucket>my-bucket-name</Bucket>
<HostId>
...
</HostId>
<Endpoint>my-bucket-name.s3.amazonaws.com</Endpoint>
</Error>
Consequently, when I follow the url http://my-bucket-name.s3.amazonaws.com/actives/photographs/000/000/001/original/20121103_132556.jpg?1388619625
in a browser, I see the picture just fine.
How do I change the endpoint in my User model? What is the normal way to handle this? I must add that my S3 bucket is the Northern California region. Thanks.