How to setup ActiveStorage to allow both public and private attachments

Viewed 153

In my Rails app, I have various models requiring uploads using ActiveStorage. Some models require signed, single use urls, and other models require public urls that do not expire.

I haven't see any options on how to differentiate between them on a per model basis.

Is this possible with ActiveStorage, or is it all or nothing regarding public and private uploads?

1 Answers

Active Storage doesn't seem to support permanent, non-expiring URLs,maybe you can configure your own controller action which redirects to the attachment URL.

eg

def show
  redirect_to or send_data
end

Then use the url pointed to this action in the place you want.

Related