Set the service in config/environments/<environment>.rb:
config.active_storage.service=:uploadcare_public
Now you can use ActiveStorage as usual:
classUser < ApplicationRecordhas_one_attached:avatarenduser=User.createuser.avatar.attach(io: File.open('/path/to/file')putsuser.avatar.url# will print something like:# https://ucarecdn.com/0e8b1b1e-5b3e-4e4e-9b1b-1e5b3e4e4e9b/
Limitations and specifics
ActiveStorage::Uploadcare doesn't support direct uploads. You need to upload files via your server.
ActiveStorage has file variants feature. But Uploadcare has its own image transformations. For example, images are transformed on the fly, and automatically cached on the CDN. You don't need to worry about storing and processing variants. So, with ActiveStorage::Uploadcare service variant become redundant.