Trying to create an image uploader using paperclip , aws-sdk gem and Amazon S3. get error Aws::Errors::MissingRegionError in ProjectsController#create. Missing region; use :region option or export region name to ENV['AWS_REGION']. using Oregon region.
projects_controller.rb
def create
@project = current_user.projects.new(project_params)
@project.save
respond_with(@project)
end
application.rb file
config.paperclip_defaults = {
storage: :s3,
s3_host_name: "s3-us-west-2.amazonaws.com",
s3_credentials: {
bucket: ENV['AWS_BUCKET'],
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
}
}
according to s3 documentation I understand I need to change to ENV['AWS_REGION']
config.paperclip_defaults = {
storage: :s3,
region: "ENV['AWS_REGION"],
s3_credentials: {
bucket: ENV['AWS_BUCKET'],
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
}
}
and add region to my .env file
export AWS_BUCKET=realv1
export AWS_ACCESS_KEY_ID=AKIAJYYCCCCCC23OA
export AWS_SECRET_ACCESS_KEY=1Y8GMkCCCCCCOJgd0eWxg3pHq4DLUz
export AWS_REGION="'us-west-2'
rebooted server , retested but still getting same errors
Aucun commentaire:
Enregistrer un commentaire