Ruby on rails Seahorse::Client::NetworkingError(getaddrinfo:没有这样的主机是已知的。)在使用heroku应用程序的回形针将图像上载到s3时 回形针 Gemfile
config/production.rbRuby on rails Seahorse::Client::NetworkingError(getaddrinfo:没有这样的主机是已知的。)在使用heroku应用程序的回形针将图像上载到s3时 回形针 Gemfile,ruby-on-rails,ruby,amazon-web-services,heroku,amazon-s3,Ruby On Rails,Ruby,Amazon Web Services,Heroku,Amazon S3,config/production.rb Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
config.paperclip_defaults = {
storage: :s3,
:s3_region => ENV['AWS_REGION'],
s3_credentials: {
bucket: ENV['S3_BUCKET_NAME'],
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
}
}
end
我正在使用回形针的
beta版(5.0.0)和aws sdk~>2.3
。问题就像当我试图使用回形针将图像上传到s3时,它在标题中给出了上述错误。我已经准备好了,我觉得没用。请帮助我,我被困在这大约2天。提前谢谢你 您引用的博文是为2.0版之前的AWS SDK编写的。由于您使用的是gem'aws sdk','~>2.2','>=2.2.35',因此需要定义区域
所以不是
Paperclip::Attachment.default_options[:s3_host_name] = 's3-us-west-2.amazonaws.com'
你会用
Paperclip::Attachment.default_options[:s3_region] = 'us-west-2'
请务必参考回形针文档,因为它从今天起是最新的。请将bucket移出s3\u凭据,我们需要s3\u主机名才能从Amazon s3访问文档
config.paperclip_defaults = {
storage: :s3,
s3_region: ENV['AWS_REGION'],
s3_host_name: ENV['AWS_HOST_NAME'],
bucket: ENV['S3_BUCKET_NAME']
s3_credentials: {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
}
}
还要确保您的IAM用户具有正确的S3权限,并且您正在为S3\u区域使用正确的值
您可以在以下链接中找到所有S3区域的列表
我已恢复到gem'aws sdk',“~>1.66.0”
。你能帮我解决这个错误吗(拒绝访问
您设置了AWS访问密钥Id和AWS秘密访问密钥吗?您可以在AWS文档中找到更多信息:ENV变量有问题。.谢谢!很高兴听到!请将我的回答标记为正确,以帮助其他人。很高兴我能帮上忙!我也有同样的问题。设置区域并删除和删除主机名字对我没有任何帮助。
Paperclip::Attachment.default_options[:s3_region] = 'us-west-2'
config.paperclip_defaults = {
storage: :s3,
s3_region: ENV['AWS_REGION'],
s3_host_name: ENV['AWS_HOST_NAME'],
bucket: ENV['S3_BUCKET_NAME']
s3_credentials: {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
}
}