Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails CarrierWave未使用Fog和S3:ArgumentError…”的命令;不是公认的存储提供商”;_Ruby On Rails_Amazon S3_Amazon Web Services_Carrierwave_Fog - Fatal编程技术网

Ruby on rails CarrierWave未使用Fog和S3:ArgumentError…”的命令;不是公认的存储提供商”;

Ruby on rails CarrierWave未使用Fog和S3:ArgumentError…”的命令;不是公认的存储提供商”;,ruby-on-rails,amazon-s3,amazon-web-services,carrierwave,fog,Ruby On Rails,Amazon S3,Amazon Web Services,Carrierwave,Fog,也许这是CarrierWave的一个bug?我在这里阅读了类似的问题,尝试了示例代码并复制了一个新的应用程序,但它不起作用 我尝试了一些旧的应用程序,它们的代码与Github上的示例类似,但现在不起作用 完整跟踪: Gemfile 这是carrierwave配置: # config/carrierwave.rb # encoding: utf-8 require 'carrierwave' CarrierWave.configure do |config| config.fog_crede

也许这是CarrierWave的一个bug?我在这里阅读了类似的问题,尝试了示例代码并复制了一个新的应用程序,但它不起作用

我尝试了一些旧的应用程序,它们的代码与Github上的示例类似,但现在不起作用

完整跟踪: Gemfile

这是carrierwave配置:

# config/carrierwave.rb
# encoding: utf-8
require 'carrierwave'

CarrierWave.configure do |config|
  config.fog_credentials = {
    :provider               => 'AWS',       # required
    :aws_access_key_id      => 'ACCESS_KEY', # required
    :aws_secret_access_key  => 'SECRET_KEY', # required
    :region                 => 'eu-west-1'  # optional, defaults to 'us-east-1'
  }
  config.fog_directory  = 'lkrails'                     # required
  config.fog_host       = 'https://lkrails.s3-eu-west-1.amazonaws.com'
  config.fog_public     = true # optional, defaults to true
  config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}  # optional, defaults to {}

   # Make the tmp dir work on Heroku
   #  config.cache_dir = "#{Rails.root}/tmp/uploads"
end
这是上传器

# uploaders/images_uploader.rb
class ImagesUploader < CarrierWave::Uploader::Base
    include CarrierWave::MiniMagick
    storage :fog

    def store_dir
        "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
    end
    version :tiny do
       process :resize_to_limit => [25, 25]
    end
    version :thumb do
       process :resize_to_limit => [50, 50]
    end
    version :medium do
        process :resize_to_limit => [120, 120]
    end

    def extension_white_list
       %w(jpg jpeg gif png)
    end

    def filename 
    if original_filename 
      @name ||= Digest::MD5.hexdigest(File.dirname(current_path))
      "#{@name}.#{file.extension}"
    end
end
#uploaders/images_uploader.rb
类ImagesUploader[25,25]
结束
版本:thumb do
处理:将_调整为_限制=>[50,50]
结束
版本:中等
处理:将_调整为_限制=>[120120]
结束
def扩展白名单
%w(jpg jpeg gif png)
结束
def文件名
如果是原始文件名
@name | |=摘要::MD5.hexdigest(File.dirname(当前路径))
“#{@name}.#{file.extension}”
结束
结束

根据您的日志文件,您的fog版本非常旧。您使用的是0.3.25,最近的标记是1.1.2。尝试这样做:

bundle update fog

您的carrierwave版本同样已经过时,因此我也要
捆绑更新carrierwave
。这将有助于纠正此问题。

为完整性添加此项

在用这个错误消息将我的头撞在墙上几个小时后,我发现我在carrierwave初始值设定项的开头有一行:

if Rails.env.test?
  ...

因此,初始值设定项仅在测试环境中考虑。删除后,一切正常。

在发布多个问题的复制和粘贴时要小心,这些问题往往被社区标记为“垃圾邮件”。如果你这样做,那么通常意味着问题是重复的,所以请将它们标记为重复的。@Kev抱歉。这些问题是相关的,并显示为该错误消息的前两个谷歌结果,但问题不是重复的。我只是希望能从其他人那里节省一些时间来处理这个错误。
if Rails.env.test?
  ...