[fog] is not a recognized storage provider #62

Closed
noazark opened this Issue Oct 5, 2012 · 2 comments

Projects

None yet

3 participants

@noazark

This issue is, for the most part, identical to carrierwaveuploader/carrierwave#836, however to quote @bensie:

Please post mongoid issues on jnicklas/carrierwave-mongoid

Setup

# Gemfile

gem 'rails', '3.2.8'

gem 'carrierwave'
gem 'carrierwave-mongoid', :git => "git://github.com/jnicklas/carrierwave-mongoid.git", :branch => "mongoid-3.0", :require => 'carrierwave/mongoid'
gem 'mongoid', '3.0.5'
...
# config/initializers/carrierwave.rb
CarrierWave.configure do |config|
  config.storage = :fog
  config.fog_credentials = {
    :provider => 'AWS',
    :aws_access_key_id => '...',
    :aws_secret_access_key => '...'
  },
  config.fog_directory = 'uploads'

  # other options don't change the result...
end

Here are my tests, although the problem isn't specific to testing.

# spec/uploaders/document_uploader_spec.rb

require 'carrierwave/test/matchers'
require 'tempfile'
require 'spec_helper'

describe DocumentUploader do
  include CarrierWave::Test::Matchers

  before do
    DocumentUploader.enable_processing = true
    @uploader = DocumentUploader.new(@user, :avatar)
    @uploader.store!(Tempfile.new('foo')) # error thrown here
  end

  after do
    DocumentUploader.enable_processing = false
    @uploader.remove!
  end

  it "should make the image readable only to the owner and not executable" do
    @uploader.should have_permissions(0600)
  end
end
# app/uploaders/document_uploader.rb

class DocumentUploader < CarrierWave::Uploader::Base
  permissions 0600
end

The Problem

Any time I try storing a file the error is not a recognized storage provider is thrown. The exact error from the tests is:

Failure/Error: @uploader.store!(Tempfile.new('foo'))
ArgumentError:
  is not a recognized storage provider

Using :file storage works just fine and all tests pass, its only when switching to :fog that the problem comes up.

I really don't think this is a mongoid issue, I haven't seen anything to justify it as a culprit. This error has also come up in carrierwaveuploader/carrierwave#770, but it seems to be caused by a different problem.

@rmm5t
CarrierWave member

Hmm. I'm not sure this is a carrierwave-mongoid issue either. To clarify, you're using carrierwave mongoid just for the document mount_uploader support, but are storing the file on AWS?

Is this still an issue for you?

I think a pull-request with a failing test case in the carrierwave project itself would help more. If it really is an issue with carrierwave-mongoid (something this project is doing to break other storage providers), please submit a PR with a failing test case here instead.

Closing this issue out until a PR with failing test case is submitted by someone.

@rmm5t rmm5t closed this Jan 15, 2013
@stabenfeldt

I have the same issue here.
Using postgres, carrierwave (0.8.0) and carrierwave_direct (0.0.8)

Creating and inspecting the @uploader object from console:

1.9.3p194 :012 > @uploader.send(:storage)
#<CarrierWave::Storage::Fog:0x7f7fc2072b48
    attr_reader :uploader = #<ImportFileUploader:0x7f7fc132a850
        @storage = ...CarrierWave::Storage::Fog...,
        attr_reader :model = #<Importer:0x007f7fbee020a0> {
                    :id => nil,
               :user_id => 19,
            :created_at => nil,
            :updated_at => nil
        },
        attr_reader :mounted_as = :file_to_import

Error message

ArgumentError in Subscribers#new

Showing app/views/subscribers/new.html.slim where line #42 raised:

 is not a recognized storage provider
Extracted source (around line #42):

42:     = direct_upload_form_for @uploader do |f|
43:       p= f.file_field :file_to_import
44:       p= f.submit "Upload Image"

Controller

  def new
    @uploader = @current_user.importers.new.file_to_import
    @uploader.success_action_redirect = subscribers_process_import_url
  end

ImportFileUploader

class ImportFileUploader < CarrierWave::Uploader::Base
  include CarrierWave::MimeTypes
  process :set_content_type

  include Sprockets::Helpers::RailsHelper
  include Sprockets::Helpers::IsolatedHelper
  include CarrierWaveDirect::Uploader

end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment