My question is really two things: 1. Why is it putting my app name twice? 2. Why can't I change file path?
我的问题实际上是两件事:1。为什么要将我的应用名称放两次? 2.为什么我不能改变文件路径?
In production, when I set s3_host_name to "s3.amazonaws.com" image upload works, but it does not show images on views.
在制作中,当我将s3_host_name设置为“s3.amazonaws.com”时,图像上传工作,但它不会在视图上显示图像。
When I set it to "myappname.s3.amazonaws.com" It then goes here: http://myappname.s3.amazonaws.com/myappname/properties/avatars/4/medium.jpg
当我将它设置为“myappname.s3.amazonaws.com”时它会转到此处:http://myappname.s3.amazonaws.com/myappname/properties/avatars/4/medium.jpg
Which is still not correct because the path should be: http://myappname.s3.amazonaws.com/properties/avatars/4/medium.jpg
这仍然是不正确的,因为路径应该是:http://myappname.s3.amazonaws.com/properties/avatars/4/medium.jpg
I've also tried not setting versions for the gems, and try aws v2.
我也尝试过不为宝石设置版本,并尝试使用aws v2。
All s3 permissions have been set to work as well, so when manually putting the correct path on the view the image shows up.
所有s3权限都设置为也可以使用,因此当手动在视图上放置正确的路径时,图像会显示出来。
Gems:
gem "paperclip", '~> 4.3'
gem 'aws-sdk', '1.63.0' #(also tried unspecified and 2)
Production.rb:
config.paperclip_defaults = {
:storage => :s3,
:s3_host_name => "myappname.s3.amazonaws.com",
:path => "/properties/avatars/:id/:style.:extension",
:region => 'us-west-1',
:s3_credentials => {
:bucket => ENV['S3_BUCKET_NAME'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}
This is the error (heroku logs):
这是错误(heroku日志):
OpenSSL::SSL::SSLError (hostname "myappname.myappname.s3.amazonaws.com"
When setting =
设置=时
:s3_host_name => "myappname.s3.amazonaws.com"
BUT
:s3_host_name => "s3.amazonaws.com"
Just sets it to 's3.amazonaws.com'
只需将其设置为's3.amazonaws.com'
My question is really two things: 1. Why is it putting my app name twice? 2. Why can't I change file path?
我的问题实际上是两件事:1。为什么要将我的应用名称放两次? 2.为什么我不能改变文件路径?
1 个解决方案
#1
0
Just set to this:
只需设置为:
config.paperclip_defaults = {
:storage => :s3,
:s3_host_name => 's3-us-west-1.amazonaws.com',
:s3_credentials => {
:bucket => ENV['S3_BUCKET_NAME'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}
#1
0
Just set to this:
只需设置为:
config.paperclip_defaults = {
:storage => :s3,
:s3_host_name => 's3-us-west-1.amazonaws.com',
:s3_credentials => {
:bucket => ENV['S3_BUCKET_NAME'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}