Dave Dave - 27 days ago 9
Ruby Question

Error trying to upload a photo using carrier wave and s3

This is my error in the terminal,

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

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

this is the view page

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

this is my fog file,

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 {}

any help will be much appreciated

def create
@property = Property.new(property_params)

if @property.save
redirect_to root_path
render 'new'

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


it wants me to add more details, so I have tried changing the regions etc...

also do I need 'excon'

Answer Source

Change the CarrierWave configuration option host to point to 's3.amazonaws.com' instead of 's3.example.com'