Skip to content

Instantly share code, notes, and snippets.

@leemour
Last active July 1, 2021 10:37
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save leemour/1cba4aa37da14136731259b9e8fb11a5 to your computer and use it in GitHub Desktop.
Save leemour/1cba4aa37da14136731259b9e8fb11a5 to your computer and use it in GitHub Desktop.
Carrierwave integration with Selectel using fog-openstack
CarrierWave.configure do |config|
if Rails.env.test? || Rails.env.cucumber?
config.storage = :file
config.enable_processing = false
else
config.asset_host = Rails.application.secrets.asset_host
config.fog_provider = 'fog/openstack'
config.fog_credentials = {
provider: 'OpenStack',
openstack_auth_url: 'https://api.selcdn.ru/v3',
# Create a new user with limited bucket access
openstack_username: Rails.application.secrets.selectel[:username],
# User password, not API key
openstack_api_key: Rails.application.secrets.selectel[:password],
}
# required
config.fog_directory = Rails.application.secrets.selectel_container
# optional, defaults to true
config.fog_public = true
# optional, defaults to {}
config.fog_attributes = {
cache_control: "public, max-age=#{365.days.to_i}"
}
config.storage = :fog
end
end
# paramsv3 = {
# openstack_auth_url: 'https://api.selcdn.ru/v3',
# openstack_username: Rails.application.secrets.selectel[:username],
# openstack_api_key: Rails.application.secrets.selectel[:password],
# }
# paramsv2 = {
# openstack_auth_url: 'https://api.selcdn.ru/v2.0',
# openstack_username: Rails.application.secrets.selectel[:username],
# openstack_api_key: Rails.application.secrets.selectel[:password],
# openstack_identity_api_version: 'v2.0'
# }
# service = Fog::OpenStack::Storage.new(paramsv2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment