How to add a custom service to ActiveStorage
问题 I want to add a custom service to ActiveStorage because I want to overwrite the url method of the ActiveStorage::Service::S3Service service so I can use a CloudFront CDN in front of my S3 bucket. I think I will not need the presigned_url params, I will just need the key, because the CloudFront instance will have full read access to the S3 bucket. 回答1: Add a class in the ActiveStorage::Service namespace that subclasses ActiveStorage::Service::S3Service . Override the methods you want to