When Active Storage creates a signed variant URL, it sets a default timeout of 5.minutes
. I really want to increase this, but I've been trawling Github issues, code diving and cannot find it anywhere.
On line 44 of the services class a class_attribute
is set, but how can this be overwritten?
https://github.com/rails/rails/blob/5-2-stable/activestorage/lib/active_storage/service.rb#L44
I'm using url_for
to generate the signed variant links and there doesn't seem to be anyway to change the setting then.
Any help would be greatly appreciated.
Thank you! :)
1 What is Active Storage? Active Storage facilitates uploading files to a cloud storage service like Amazon S3, Google Cloud Storage, or Microsoft Azure Storage and attaching those files to Active Record objects.
After creating a new application (or upgrading your application to Rails 5.2), run bin/rails active_storage:install to generate a migration that creates these tables. Use bin/rails db:migrate to run the migration. active_storage_attachments is a polymorphic join table that stores your model's class name.
A blob is a record that contains the metadata about a file and a key for where that file resides on the service. Blobs can be created in two ways: Subsequent to the file being uploaded server-side to the service via create_after_upload!.
Set ActiveStorage::Service.url_expires_in
directly, e.g. in an initializer:
# config/initializers/active_storage.rb
ActiveStorage::Service.url_expires_in = 1.hour
Rails 6 will add config.active_storage.service_urls_expire_in
:
# config/initializers/active_storage.rb
Rails.application.config.active_storage.service_urls_expire_in = 1.hour
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With