I am using carrierwave with fog to store images on amazon's s3. I've followed all the guides, but i keep getting the same basic error and it seems incorrectly.
Errno::EACCES in ProjectsController#update
Permission denied - C:/rails-projects/myrailsapp/tmp/20111203-2006-7864-6681/jolly-rows.jpg
however, the uploaded image is still being placed in the cached dir and it's being uploaded to the amazon s3 server.... so why is it throwing this error?
i have
CarrierWave.configure do |config|
config.root = Rails.root.join('tmp')
config.cache_dir = 'carrierwave'
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => 'SECRET',
:aws_secret_access_key => 'SECRET'
}
config.permissions = 0777
config.fog_directory = 'ia_test_dir'
config.fog_public = true
end
in an initializer. please help...thanks!
Update: still haven't been able to get this to work. I've a few other things, like changing the tmp dir, not setting the tmp, etc.. and nothing please help. anyone?
Is there something my question is missing that's keeping people from responding?
Related
I have deployed my app on Ninefold, but it crashes when I try uploading pictures. The logs suggest that I'm missing my AWS credentials:
ArgumentError (Missing required arguments: aws_access_key_id, aws_secret_access_key)
But I'm fairly sure I've got them set up correctly using Fog and my .env file. CarrierWave initializer looks like this at the moment:
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => ENV['S3_KEY'], # required
:aws_secret_access_key => ENV['S3_SECRET'], # required
:region => 'us-east-1' # optional, defaults to 'us-east1'
}
config.fog_directory = ENV['S3_BUCKET'], # required
end
Any suggestions on how to get this working correctly? Don't know what other info to give but if you need more info to help me solve let me know.
Have you set the environment variables in your app?
You need to add some variables with the relevant names in the Environment Variables section under the app deploy.
S3_KEY
S3_SECRET
S3_BUCKET
You amazon account should have the relevant details.
I just pulled an older version of a project I'm working on in rails from github and am having problems with carrierwave for image upload. I used the figaro gem to store my secret keys so they were not in the file I pulled down (figaro puts an application.yml file that then gets listed in .gitignor). So I added the figaro configuration, but carrierwave still refuses to work. I even tried putting the keys into the carrierwave configuration directly to see if it was something with figaro, but no luck.
My config/initializers/carrierwave.rb
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => ENV['AWS_KEY_ID'],
:aws_secret_access_key => ENV['AWS_SECRET_KEY'],
:region => 'us-east-1',
}
config.fog_directory = 'bucketname'
config.fog_public = true
config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}
end
I am pretty sure that my keys are being stored properly in my development environment, but I have no idea why carrierwave is not working like it did before.
Thanks!
I have a Rails app that is using Carrierwave for file uploads. It has been working fine but I want to start using Amazon S3 for my image storage. I am getting this error:
ArgumentError ( is not a recognized storage provider):
app/controllers/salons_controller.rb:52:in `update'
I have made sure I have the latest gems for Carrierwave and Fog. This is in my Gemfile:
gem 'carrierwave'
gem 'aws-sdk'
gem 'fog'
fog.rb looks like:
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => 'MYACCESSKEY',
:aws_secret_access_key => 'MYSECRETKACCESSKEY',
:region => 'us-east-1'
}
config.fog_directory = 'andrunix'
config.fog_public = true
config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}
end
The Uploader class looks like:
class SalonImageUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
storage :fog
def store_dir
# "andrunix" is the bucket name on S3
"andrunix/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
If I change the storage back to 'file', it works fine. Setting storage to 'fog' generates this error.
OK, I'm an idiot. :)
At some point, I don't know where, I added a fog.rb file with my CarrierWave configuration to the lib/carrierwave/storage directory. I got desperate, paid for a Railscasts subscription so I could watch episode #383 (http://railscasts.com/episodes/383-uploading-to-amazon-s3?autoplay=true) and at 3:02 I found the error of my ways. The Carrierwave configuration needed to be placed in config/initializers/carrierwave.rb.
I don't know where I got this other location but once I moved the config to the proper location, everything is good.
I just ran into the same problem, and people must be aware that any typo in the config file : "config/initializers/carrierwave.rb", leads to that error.
I have two carrierwave uploaders in my application. ImageUploader is for uploading locally and ImageRemoteUploader for uploading to Amazon S3 storage using fog. ImageUploader has storage set to :file and ImageRemoteUploader has storage set to :fog. This setup works fine, but when I start to set up my rspec tests, things change.
The problem arises when I change the ImageRemoteUploader to use :file storage during testing. I do this in my fog initialization file. The file,
/config/initializers/fog.rb, looks like:
CarrierWave.configure do |config|
if Rails.env.test?
config.storage = :file
config.enable_processing = false
else
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => 'XXXXXXXX', # required
:aws_secret_access_key => 'XXXXXX', # required
:region => 'XXXX' # optional, defaults to 'us-east-1'
}
config.fog_directory = 'xxx' # required
config.fog_public = true
end
end
When I do this, I get an ArgumentError is not a recognized storage provider carrierwave exception. When I use the fog credentials (I don't set config.storage to :file), the test works as expected.
Carrierwave 0.7.1, Rails 3.2.8, Ruby 1.9.3, Rspec 2.10
Thanks.
I'd try moving the config.storage and config.enable_processing lines into lib/initializers/carrierwave.rb, as recommended in the Carrierwave docs.
Fog also has its own mocking support, which is enabled by running Fog.mock! before the examples. This might be a better approach.
My problem is really similar to this one:
rails + carrierwave + fog + S3 socket error
I was experimenting with regions but without a luck.
I'm trying to use carrierwave + fog + amazon s3 as described on wiki and in few similar questions here on stackoverflow. So, here are my files:
config/initializers/carrierwave.rb
CarrierWave.configure do |config|
config.fog_directory = 'folder_name_here' # my bucket name
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => 'access_key_here', # copied from amazon
:aws_secret_access_key => 'secret_key_here', # copied from amazon
:region => 'eu-west-1' # my bucket has region set to Ireland
}
end
My uploader has a storage parameter set to :fog.
And now, when i'll try to save my model, i'm getting the following error:
getaddrinfo: Name or service not known (SocketError)
Have you any idea what am i possibly doing wrong? If any further info is needed, please just let me know.
Did you restart your server when adding in the carrierwave and fog gem?