local: service: Disk root: <%= Rails.root.join("storage") %> # Use bin/rails credentia" /> local: service: Disk root: <%= Rails.root.join("storage") %> # Use bin/rails credentia" /> local: service: Disk root: <%= Rails.root.join("storage") %> # Use bin/rails credentia"/>

How to attach NFS using active storage in rails 7

29 Views Asked by At
test:
  service: Disk
  root: <%= Rails.root.join("tmp/storage") %>

local:
  service: Disk
  root: <%= Rails.root.join("storage") %>

# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
# amazon:
#   service: S3
#   access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
#   secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
#   region: us-east-1
#   bucket: your_own_bucket-<%= Rails.env %>

This is my storage.yml. Now my question is In my other app which is rails 6 I am using carrier wave gem, I have customized the place where my files should be saved. I have used NFS

This is my rails 6 code where I am using nfs in production and downloads in development

def store_dir
    if Rails.env.production?
      "/#{ENV['NFS_PATH']}/abc/#{model.class.to_s.underscore}/#{model.created_at.year}/#{model.created_at.month}/#{model.created_at.to_date.strftime('%d')}/#{mounted_as}/#{model.try(:id)}"
    else
      "~/Downloads/#{model.class.to_s.underscore}/#{model.created_at.year}/#{model.created_at.month}/#{model.created_at.strftime('%d')}/#{mounted_as}/#{model.try(:id)}"
    end
  end
end

Is there any way in rails 7 to achive this to upload files in nfs. Can I add another group like test and local which are defined by default in storage.yml??

0

There are 0 best solutions below