应该是一个很简单的解决这个问题,我想,但我似乎无法让它上班.我有一个Rails 4应用程序,一个带有Paperclip的照片属性设置的用户模型,我将其链接到S3.
以下是用户模型:
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时,我看到图片很好.