Reputation: 1
I want to use my minio cdn to add assets from rails using carrierwave.
My CarrierWave config looks like:
CarrierWave.configure do |config|
config.fog_provider = 'fog/aws'
config.fog_credentials = {
:provider => 'AWS',
:aws_secret_access_key => ENV.fetch("MINIM_SECRET_KEY"),
:aws_access_key_id => ENV.fetch("MINIO_ACCESS_KEY"),
:region => 'ap-east-1',
:host => "cdn.doamin.in",
:endpoint => "https://cdn.doamin.in:9000",
}
config.fog_directory = ENV.fetch('DEPLOYMENT')=="STAGE" ? 'doamin-assets-stage': 'doamin-assets'
config.fog_attributes = {
debug_request: true
}
end
I know minio is compatible with aws and it works like wonder when i use it like the following
require 'aws-sdk-core'
Aws.config.update(
endpoint: 'https://cdn.domain.in',
access_key_id: ENV.fetch("MINIO_ACCESS_KEY"),
secret_access_key: ENV.fetch("MINIM_SECRET_KEY"),
force_path_style: true,
region: "ap-south-1"
)
$cdn_client = Aws::S3::Client.new
uploaded = $cdn_client.put_object(key: key, body: params\[:file\], bucket: bucket, content_type: content_type)
if uploaded\[:etag\] != nil
file_path = "https://cdn.domain.in/#%7Bbucket%7D/#%7Bkey%7D"
How can set carrier wave config so that I don't get error when creating for
class Model < ApplicationRecord
mount_base64_uploader :image_url, ModelImageUploader
in controllers
Model.create(params)
the error I get:
Exception === no address for domain-assets-stage.cdn.domain.in (Resolv::ResolvError)
there is no sub domain for my buckets the first part of this address is bucket followed by domain in carrierwave config.
I was expecting to use carrierwave just like how I use $cdn_object to store assets associated with models.
Upvotes: 0
Views: 93