我认为这个问题应该很容易解决,但是我似乎无法让它正常运行。我有一个Rails 4应用程序,一个User模型,其中设置了一个photograph
属性,并使用Paperclip进行链接,我将其链接到了S3。
以下是User模型:
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
图片已成功添加到我的S3存储桶中,但当我尝试使用<%= image_tag @user.photograph.url %>
来渲染该图片时,它没有显示出来。经过进一步检查,该图片的URL为:
http://s3.amazonaws.com/my-bucket-name/users/photographs/000/000/001/original/20121103_132556.jpg?1388619625
如果我在浏览器中按照此URL进行访问,则会看到以下XML文件:
<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>
因此,当我在浏览器中跟随网址http://my-bucket-name.s3.amazonaws.com/actives/photographs/000/000/001/original/20121103_132556.jpg?1388619625
时,我可以正常看到图片。
我该如何更改我的用户模型中的终端节点?处理这种情况的正常方式是什么?需要注意的是,我的S3存储桶位于加利福尼亚北部地区。谢谢。