ActiveStorage to local files server with custom paths

I have a rails 6.1.3 app that is developed from Rails 1.2. I was used to deal with PDF (prawn) and images using ruby’s File library. I have two servers : the first one runs rails, the second one is a file server. Users can access to files and modify them. ActiveStorage works well for logos and avatars (rails server storage), but I would like to use ActiveStorage to deals with my file server (and store files with my custom paths). I’ll use some interesting features such as representation of PDF files. Is there a way to configure it without deploy a cloud service ? Thanks a lot

Active Storage has a disk service, that allows you to specify where you want files to be saved in the web server (or network path):

Thank you Breno for your help. I didn’t try with a network path, reading guide let me think it was only on Rails.root (I have more lines in database.yml for example, like host).

Anyway, how to deals with custom paths ? For example, I have one directory for each customers where I put generated PDF and every files (pictures, estimates etc.) concerning this customer.

From my Agreement model :

def directory
  File.join("/mnt", "fichiers", "Clients",, "#{number}/")

def pdf_url
  directory + File.join("Agreement #{number}#{' - v' + version.to_s if version > 1}.pdf")

As I saw, ActiveStorage generate lot of folders inside a root, and they aren’t friendly user :slight_smile: I found ActiveStorage custom storage path configuration per Model attribute · Issue #38161 · rails/rails · GitHub, but I need user readable filename. May be ActiveStorage isn’t a good choice for my requirements…

Thanks again for your help

Unfortunately, that feature is not available. If you want custom folders like that you will have to implement your own Active Storage service (which you can probable inherit from DiskService and just change what you need).