- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
看了好几篇相关的帖子和解决方案,还是想不通,还是返回“Excon::Errors::SocketError 在/postsgetaddrinfo: nodename 或 servname 提供,或未知 (SocketError)”
这是config/carrierwave.rb
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => '----', # required
:aws_secret_access_key => '----', # required
:region => 'eu-west-1', # optional, defaults to 'us-east-1'
:host => 's3.example.com', # optional, defaults to nil
:endpoint => 'https://s3.example.com:8080' # optional, defaults to nil
}
config.fog_directory = 'name_of_directory' # required
config.fog_public = false # optional, defaults to true
config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} # optional, defaults to {}
config.asset_host = 'https://assets.example.com'
end
avatar_upload.rb
# encoding: utf-8
class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :fog
process :resize_to_fit => [900,500]
version :thumb do
process :resize_to_fill => [200,200]
end
def cache_dir
"#{Rails.root}/tmp/uploads"
end
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def default_url
# # For Rails 3.1+ asset pipeline compatibility:
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
#
"/images/fallback/" + [version_name, "default.png"].compact.join('_')
end
def extension_white_list
%w(jpg jpeg gif png)
end
end
来自后 Controller
def create
@post = Post.new(post_params)
@post.user = current_user
unless current_user.admin?
unless current_user.manager?
redirect_to :back, :alert => "acces denied"
end
end
respond_to do |format|
if @post.save
params[:photo_attachments]['avatar'].each do |a|
@photo_attachment = @post.photo_attachments.create!(:avatar => a, :post_id =>@post.id)
end
format.html { redirect_to @post, notice: 'Post was successfully created.' }
format.json { render :show, status: :created, location: @post }
else
format.html { render :new }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end
安装 carrierwave-aws 后更新了 config/carrierwave.rb
CarrierWave.configure do |config|
config.storage = :aws
config.aws_bucket = ENV['S3_BUCKET_NAME']
config.aws_acl = :public_read
config.asset_host = 'http://example.com'
config.aws_authenticated_url_expiration = 60 * 60 * 24 * 365
config.aws_credentials = {
access_key_id: ENV['---'],
secret_access_key: ENV['---']
}
end
更改为存储后:aws
AWS::Errors::MissingCredentialsError
Missing Credentials.
Unable to find AWS credentials. You can configure your AWS credentials
a few different ways:
* Call AWS.config with :access_key_id and :secret_access_key
* Export AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to ENV
* On EC2 you can run instances with an IAM instance profile and credentials
will be auto loaded from the instance metadata service on those
instances.
* Call AWS.config with :credential_provider. A credential provider should
either include AWS::Core::CredentialProviders::Provider or respond to
the same public methods.
= Ruby on Rails
In a Ruby on Rails application you may also specify your credentials in
the following ways:
* Via a config initializer script using any of the methods mentioned above
(e.g. RAILS_ROOT/config/initializers/aws-sdk.rb).
* Via a yaml configuration file located at RAILS_ROOT/config/aws.yml.
This file should be formated like the default RAILS_ROOT/config/database.yml
file.
最佳答案
这可能是因为使用了 fog
的实现,也许尝试将您的 gem 切换到 carrierwave-aws
并查看它是否解决了您的问题:)
https://github.com/sorentwo/carrierwave-aws
我记得有过类似的错误,更改后,工作正常!
关于ruby-on-rails - 载波 Excon::Errors::SocketError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25029663/
我正在开发Shopify主题,并且正在使用https://github.com/Shopify/shopify_theme将文件更新到Shopify。 不幸的是,我无法正常工作...当我尝试上传/更新
看了好几篇相关的帖子和解决方案,还是想不通,还是返回“Excon::Errors::SocketError 在/postsgetaddrinfo: nodename 或 servname 提供,或
我正在尝试遵循this neo4j教程,但是在连接到API时遇到问题。这是我的回溯: >>> graph.delete_all() Traceback (most recent call last):
我想在服务器和客户端之间建立连接,所以服务器向客户端发送一个字符串。 这是服务器: import socket def Main(): host = '190.176.141.23'#ip c
我正在尝试在远程 Ubuntu 服务器上设置 Flask/Neo4j 应用程序,但遇到了一个我无法解决的问题。我的应用程序使用 py2neo,但是当它尝试连接到图表时,应用程序崩溃并且 Neo4j 进
将 Ruby on Rails 与 Carrierwave + Fog 结合使用,它依赖于 Excon 连接到 S3。 Rails 服务器正在 AWS EC2 上运行。大多数时候,Carrierwav
尝试在 C9.io 中启动我的 Rails 应用程序时,我看到下面的套接字错误。我不确定如何纠正这个问题。有什么想法吗? ruby 2.3.0p0(2015-12-25 修订版 53290)[x86_
我得到了 GitLab 5.4 使用 Bitnami Stack 5.4.0-0 创建用户,登录并添加 key 后,推送到新存储库时 git@gitlab.funshion.com:gitdemo1
我在 Ruby 中使用 Mandrill-api 以编程方式发送交易电子邮件。 我的 Rails 应用程序中(或多或少)有以下行, mandrill ||= Mandrill::API.new con
在EFK设置中,由于日志中出现以下错误,因此fluentd突然停止发送到elasticsearch: 2020-09-28 18:48:55 +0000 [warn]: #0 Could not co
我制作了一个并行解析文本文件和下载数据的程序。在9个或更少的线程中运行下载方法时,程序没有错误。但是当在 10 个或更多线程中运行该方法时,程序会抛出“`initialize': getaddrinf
我使用 py2neo 2.0 执行长时间运行(5 分钟)的 Cypher 查询: graph.cypher.run(query)或 result = graph.cypher.execute(quer
我在 Ruby on Rails 中使用 Tire gem 来使用 Elasticsearch 进行搜索。在我的本地机器上它工作得很好。 在我的登台服务器上,我(随机?)收到此错误:SocketErr
我正在尝试在已连接的 SSL 套接字断开互联网连接时获得信号。这是我派生 QSslSocket 的方式: struct CloudSSL::Socket : public QSslSocket {
我可以将 SetBuffer 与 SocketAsyncEventArgs 一起使用。 如果我尝试使用 BufferList(在执行 SetBuffer(null, 0, 0) 之后),当我在套接字上
我希望能够说明当 Open-Uri open() 调用超时或引发诸如 SocketError 之类的异常时,我正在按预期处理事情,但是我在这方面遇到了麻烦。 这是我的规范(针对 SocketError
我目前收到以下错误:Excon::Errors::SocketError - Broken pipe (Errno::EPIPE)上传大于 150kb 的图像时。 150kb 以下的图像正常工作。研究
我正在使用NetBeans IDE 8,ruby-2.2.0-p0,mysql2,iMac,OS X 10.9.5 我试图在生产模式下运行我的应用程序,我得到: => Booting WEBri
我正在尝试在Rails应用程序中运行docker容器,但是我一直收到以下错误:- container = Docker::Container.create({'Image' => 'mitc/judg
成功引导后 bundle exec knife zero bootstrap root@139.59.210.225 我正在尝试将我的 Recipe 应用到远程使用 bundle exec knife
我是一名优秀的程序员,十分优秀!