作者:郑小蒜9299_941611_G | 来源:互联网 | 2023-09-07 00:35
Ihaveinstalledcarrierwaveandfog,havesuccessfullyuploadedtheimagesandviewedthemthefirs
I have installed carrierwave and fog, have successfully uploaded the images and viewed them the first time, but now it does not show the images anymore.
Here is my config file app/config/initializers/carrierwave.rb
我已经安装了carrierwave和fog,已经成功上传图片并第一次观看,但是现在已经不显示图片了。这是我的配置文件app/配置/初始化器/carrierwave.rb
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => 'AKIAJKOHTE4WTXCCXAMA', # required
:aws_secret_access_key => 'some secret key here', # required
:region => 'eu-east-1', # optional, defaults to 'us-east-1'
:host => 'https://s3.amazonaws.com', # optional, defaults to nil
:endpoint => 'https://s3.amazonaws.com:8080' # optional, defaults to nil
}
config.fog_directory = 'createmysite.co.za' # required
config.fog_public = false # optional, defaults to true
#config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} # optional, defaults to {}
end
This is what the url looks like of the image that is supposed to display
这就是url应该显示的图像的样子
when I open the image url this is the output from amazon https://img.php1.cn/3cd4a/189d8/b64/5b34b53b79a39fdd.jpeg?AWSAccessKeyId=AKIAJKOHTE4WTXCCXAMA&Signature=8PLq8WCkfrkthmfVGfXX9K6s5fc%3D&Expires=1354859553
当我打开图像url时,这是来自amazon https://createmysite.co.za.s3.5 = amazonawawawawawawawawawawawawawawawawawawawawawawaws.com/uploads/portfolio/portfolio/image/3/normal_selection_003.png?
AccessDenied
Access Denied
3F179B7CE417BC12
zgh46a+G7UDdpIHEEIT0C/rmijShOKAzhPSbLpEeVgUre1iDc9f7TSOwaJdQpR65
Update
new config file (added fog url expiry) app/config/initializers/carrierwave.rb
新的配置文件(添加了fog url过期)app/config/initializers/carrierwave.rb
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => 'AKIAJKOHTE4WTXCCXAMA', # required
:aws_secret_access_key => 'chuck norris', # required
}
config.fog_directory = 'createmysite.co.za' # required
config.fog_public = false # optional, defaults to true
config.fog_authenticated_url_expiration = 600 # (in seconds) => 10 minutes
end
works like a charm!
就像一个魅力!
1 个解决方案