```ruby
CarrierWave.configure do |config|
  if Rails.env.production? and Configuration[:aws_access_key]
    config.fog_credentials = {
      provider: 'AWS',
      host: 's3.amazonaws.com',
      endpoint: 'https://s3.amazonaws.com',
      aws_access_key_id: Configuration[:aws_access_key],
      aws_secret_access_key: Configuration[:aws_secret_key],
      fog_region: Configuration[:aws_region]
    }
    config.fog_directory  = Configuration[:aws_bucket]
    config.fog_attributes = { 'Cache-Control' => 'max-age=315576000' }  # optional, defaults to { }
  else
    config.enable_processing = false if Rails.env.test? or Rails.env.cucumber?
  end
end

module CarrierWave
  module RMagick

    def quality(percentage)
      manipulate! do |img|
        img.write(current_path){ self.quality = percentage } unless img.quality == percentage
        img = yield(img) if block_given?
        img
      end
    end

  end
end
```

Remove host and endpoint from CarrierWave configuration
user
```ruby
CarrierWave.configure do |config|
  if Rails.env.production? and Configuration[:aws_access_key]
    config.fog_credentials = {
      provider: 'AWS',
      aws_access_key_id: Configuration[:aws_access_key],
      aws_secret_access_key: Configuration[:aws_secret_key],
      fog_region: Configuration[:aws_region]
    }
    config.fog_directory  = Configuration[:aws_bucket]
    config.fog_attributes = { 'Cache-Control' => 'max-age=315576000' }  # optional, defaults to { }
  else
    config.enable_processing = false if Rails.env.test? or Rails.env.cucumber?
  end
end

module CarrierWave
  module RMagick

    def quality(percentage)
      manipulate! do |img|
        img.write(current_path){ self.quality = percentage } unless img.quality == percentage
        img = yield(img) if block_given?
        img
      end
    end

  end
end
```
assistant