it's my first Rails project with the Refile gem, so I don't fully grasp all the ins and outs of this wonderfull file upload gem yet.
I'm trying to configure the Refile gem so that files are uploaded to Amazon S3 in production mode, but in development mode files are uploaded to the file system.
my config/initializers/refile.rb file looks like this:
require "refile/backend/s3"
aws = {
access_key_id: Rails.application.secrets.s3_key,
secret_access_key: Rails.application.secrets.s3_secret,
bucket: "adlit",
}
Refile.cache = Refile::Backend::S3.new(prefix: "cache", **aws)
Refile.store = Refile::Backend::S3.new(prefix: "store", **aws)
end
but when I try to upload an image in development, I get this error message:
Missing Credentials. Unable to find AWS credentials. You can configure your AWS credentials a few different ways: * Call AWS.config with :access_key_id and :secret_access_key * Export AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to ENV *...
So I tried to fix this by adding the configuration in a conditional:
if Rails.env.production
...
end
But that didn't fix it, I still get the above error message in development mode.
Does anyone know how I can configure Refile to upload file to Amazon S3 in production and to the file system when in development mode?
thanks for your help,
Anthony