Ruby on rails 4 如何从S3存储桶中检索图像链接
我能够上传图像到s3桶。 然后检索包含图像链接的JSON对象。 这是指向存储桶的URL 网址:“ 当我按下它时,我得到一个错误Ruby on rails 4 如何从S3存储桶中检索图像链接,ruby-on-rails-4,amazon-s3,amazon,carrierwave,fog,Ruby On Rails 4,Amazon S3,Amazon,Carrierwave,Fog,我能够上传图像到s3桶。 然后检索包含图像链接的JSON对象。 这是指向存储桶的URL 网址:“ 当我按下它时,我得到一个错误 <Error> <Code>PermanentRedirect</Code> <Message> The bucket you are attempting to access must be addressed using the specified endpoint. Please send al
<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>2227C463FE87702A</RequestId>
<Bucket>bucket-name</Bucket>
<HostId>
20obskM************FmRoYcMDnMlH
</HostId>
<Endpoint>bucket-name.s3.amazonaws.com</Endpoint>
</Error>
我将RoR与carrierwave和fog gems一起使用。请使用此代码例如:
我必须替换follow并在端点中指定我的bucket区域:
:endpoint => 'https://s3.amazonaws.com'
与:
试试这个,
我面临同样的问题,并通过以下方式解决:
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => '******', # required
:aws_secret_access_key => '******', # required
}
config.fog_directory = '******' # required(Your bucket name)
config.fog_public = false # optional, defaults to true
config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} # optional, defaults to {}
end
bucket名称应该在那里!
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => '******', # required
:aws_secret_access_key => '******', # required
}
config.fog_directory = '******' # required(Your bucket name)
config.fog_public = false # optional, defaults to true
config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} # optional, defaults to {}
end