2017-09-23 119 views
0

這是我在終端錯誤上傳照片,錯誤嘗試使用載波和S3

Excon::Error::Socket (getaddrinfo: nodename nor servname provided, or not known (SocketError)): 

app/controllers/properties_controller.rb:15:in `create' 

這是視圖頁面

getaddrinfo: nodename nor servname provided, or not known (SocketError) 

這是我的大霧文件,

CarrierWave.configure do |config| 
    config.fog_provider = 'fog/aws'      # required 
    config.fog_credentials = { 
provider:    'AWS',      # required 
aws_access_key_id:  ENV['AWS_APP_KEY'],      # required 
aws_secret_access_key: ENV['AWS_APP_SECRET'],      # required 
region:    'us-east-1',     # optional, defaults to 'us-east-1' 
host:     's3.example.com',    # optional, defaults to nil 
endpoint:    's3-external-1.amazonaws.com' # optional, defaults to nil 
} 
config.fog_directory = ENV['AWS_BUCKET_NAME']       # required 
config.fog_public  = false          # optional, defaults to true 
config.fog_attributes = { cache_control: "public, max-age=#{365.day.to_i}" } # optional, defaults to {} 
end 

任何幫助將不勝感激

def create 
@property = Property.new(property_params) 

    if @property.save 
    redirect_to root_path 
    else 
    render 'new' 
    end 
end 


    private 
    def property_params 
if params[:property][:amenities].class == Array 
    params[:property][:amenities] = params[:property][:amenities].join(",") 
end 
params.require(:property).permit(:property_name, :city, :ppm, :images, :user_id, :amenities, {property_images: []}) 

end 

它要我增加更多的細節,所以我試圖改變區域等等

還做我需要「EXCON」

+0

喜戴夫,你能提供從性能控制器'create'方法? – garythegoat

+0

剛剛添加。謝謝 – Dave

+0

我認爲你需要改變CarrierWave配置選項'主機'指向''s3.amazonaws.com''而不是''s3.example.com'' – garythegoat

回答

1

更改CarrierWave配置選項主機指向的's3.amazonaws.com'代替's3.example.com'

+0

偉大的,似乎已經排序該錯誤,我'現在離開這個:壞的URI(不是URI?):: /(我的桶名稱).s3.amazonaws.com: – Dave

+0

好吧,我已經排序謝謝 – Dave

1

問題與您的配置端點,

你不需要主機輸入。 我修改了端點以使用標準的s3 url。

CarrierWave.configure do |config| 
    config.fog_provider = 'fog/aws'      # required 
    config.fog_credentials = { 
provider:    'AWS',      # required 
aws_access_key_id:  ENV['AWS_APP_KEY'],      # required 
aws_secret_access_key: ENV['AWS_APP_SECRET'],      # required 
region:    'us-east-1',     # optional, defaults to 'us-east-1' 
endpoint:    's3.amazonaws.com' # optional, defaults to nil 
} 
config.fog_directory = ENV['AWS_BUCKET_NAME']       # required 
config.fog_public  = false          # optional, defaults to true 
config.fog_attributes = { cache_control: "public, max-age=#{365.day.to_i}" } # optional, defaults to {} 
end 

參考文檔:

https://github.com/carrierwaveuploader/carrierwave/wiki/How-to:-Use-minio-with-Carrierwave

https://github.com/carrierwaveuploader/carrierwave/issues/1802

希望它能幫助。