Search code examples
ruby-on-rails-3.2capistranocarrierwavelinode

Upload images from rails to linode


So I want to upload images from my running rails 3 app wich is hosted on linode, the file upload works locally, but when i try to do it remotely it fails. I've read some options, but almost all of them looks like this:

CarrierWave.configure do |config|

  if Rails.env.development? || Rails.env.test?
    config.storage = :file
  else
  config.storage = :fog
  config.fog_credentials = {
      :provider               => 'AWS',
      :aws_access_key_id      =>  'some_access_key_id',
      :aws_secret_access_key  => 'some_secret_key',
      :region                 => 'eu-west-1'
   }
   config.fog_directory = 'bucket_name'
   end
end

but when i change it to linode options it gave me the

ArgumentError (linode is not a recognized storage provider):
  app/controllers/users_controller.rb:50:in `create'

then i took the sftp option:

CarrierWave.configure do |config|
config.sftp_host = "my.host.com"
config.sftp_user = "username"
config.sftp_folder = "public_html/uploads"
config.sftp_url = "http://my.host.com/uploads"
config.permissions = 0666
config.directory_permissions = 0777
config.storage = :file  
config.sftp_options = {
  :password => "mypass",
  :port     => 22
}
end

but i still got the same error:

ArgumentError (linode is not a recognized storage provider):
 app/controllers/users_controller.rb:50:in `create'

I'm workink with aptana and rails 3.2 using git and then deploy with capistrano after every change i make and commit. I ran into a similar question here Uploading files to Linode using CarrierWave but it has no answer. I don't know if it can be done with carrierwave but any suggestion will be taken, any help you can give is welcome.

Thank you!


Solution

  • As you have 20GB of storage on your Linode instance and your server runs already on Linode, you want to chose the carrierwave option :file - because you just want to store the images on the filesystem of your (Linode) server, not any external storage provider like S3. (Linode is not a recognized carrierwave storage provider, hence the error message)

    Try just leaving it with the same option than your development environment:

    CarrierWave.configure do |config|
        config.storage = :file
    end