У меня есть загрузчик для моего проекта rails BulkImagesUploader
, который берет zip-файл и загружает его в S3, используя carrierwave
.Это работало нормально, но я чувствую, что мне нужно загрузить файлы напрямую из браузера в S3, используя carrierwave_direct
gem.
Я следовал инструкциям на камнях README, однако получаю сообщение об ошибке
/home/moiz/.rvm/gems/ruby-2.4.1/gems/fog-0.7.2/lib/fog/core/provider.rb:5:in `extended': undefined method `providers' for Fog:Module (NoMethodError)
Ниже мой код
Gemfile
# Gemfile.rb
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '>= 2.4.1'
gem 'aasm', '~> 4.12'
gem 'acts-as-taggable-on', '~> 6.0'
gem 'acts_as_commentable'
gem 'ancestry'
gem 'bootsnap', '>= 1.1.0', require: false
gem 'cancancan'
gem 'carrierwave_direct'
gem 'carrierwave', '~> 1.0'
gem 'client_side_validations'
gem 'client_side_validations-simple_form'
gem 'coffee-rails', '~> 4.2'
gem 'devise'
gem 'dotenv-rails'
gem 'fog'
# gem 'fog-aws'
gem 'jbuilder', '~> 2.5'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'kaminari'
gem 'mini_magick', '>= 4.9.2'
gem 'mysql2'
gem 'paranoia', '~> 2.2'
gem 'puma', '~> 3.11'
gem 'rails', '~> 5.2.0'
gem 'ransack'
gem 'sass-rails', '~> 5.0'
gem 'sidekiq'
gem 'simple_form'
gem 'turbolinks', '~> 5'
gem 'uglifier', '>= 1.3.0'
gem 'wicked', '>= 1.3.3'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: %i[mri mingw x64_mingw]
gem 'factory_bot_rails'
gem 'pry'
gem 'rails-erd'
gem 'rspec-rails', '~> 3.7'
gem "switch_user"
end
group :development do
gem 'listen', '>= 3.0.5', '< 3.2'
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem "awesome_print", '~> 1.8.0', require: "ap"
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15', '< 4.0'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
gem 'database_cleaner'
gem 'faker'
gem 'guard-rspec'
gem 'launchy'
gem 'shoulda'
end
gem 'rubocop', require: false
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
Инициализатор
# config/initializers/carrierwave.rb
CarrierWave.configure do |config|
config.fog_credentials = {
provider: 'AWS',
aws_access_key_id: ENV['AWS_KEY'],
aws_secret_access_key: ENV['AWS_SECRET'],
region: ENV['AWS_REGION']
}
config.fog_directory = ENV['S3_BUCKET']
end
Uploader
class BulkImageUploader < CarrierWave::Uploader::Base
include CarrierWaveDirect::Uploader
def extension_whitelist
%w(zip)
end
end
Трассировка стека
/home/moiz/.rvm/gems/ruby-2.4.1/gems/fog-0.7.2/lib/fog/core/provider.rb:5:in `extended': undefined method `providers' for Fog:Module (NoMethodError)
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/fog-aws-3.3.0/lib/fog/aws.rb:9:in `extend'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/fog-aws-3.3.0/lib/fog/aws.rb:9:in `<module:AWS>'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/fog-aws-3.3.0/lib/fog/aws.rb:8:in `<module:Fog>'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/fog-aws-3.3.0/lib/fog/aws.rb:7:in `<main>'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/carrierwave_direct-2.0.0/lib/carrierwave_direct.rb:4:in `<main>'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.6/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.6/lib/bundler/runtime.rb:76:in `each'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.6/lib/bundler/runtime.rb:76:in `block in require'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.6/lib/bundler/runtime.rb:65:in `each'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.6/lib/bundler/runtime.rb:65:in `require'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.6/lib/bundler.rb:114:in `require'
from /home/moiz/Desktop/Projects/ca-bfl/config/application.rb:7:in `<main>'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:145:in `block in perform'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in `tap'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in `perform'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/command/base.rb:65:in `perform'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/command.rb:46:in `invoke'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/commands.rb:18:in `<main>'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
from /home/moiz/Desktop/Projects/ca-bfl/bin/rails:9:in `<top (required)>'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
from /home/moiz/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
from /home/moiz/Desktop/Projects/ca-bfl/bin/spring:15:in `require'
from /home/moiz/Desktop/Projects/ca-bfl/bin/spring:15:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
Что может быть причиной этой ошибки?