Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add expires_at option to ActiveStorage::Blob#signed_id #48115

Merged
merged 1 commit into from Sep 26, 2023

Conversation

aki77
Copy link
Contributor

@aki77 aki77 commented May 2, 2023

Motivation / Background

When using the expires_in option to generate an expiration URL, the URL will change each time.
By using the expires_at option as shown in the example below, the browser cache can be used for a certain period of time.

rails_blob_path(user.avatar, disposition: "attachment", expires_at: 2.hours.from_now.beginning_of_hour)
<%= image_tag rails_blob_path(user.avatar.variant(resize: "100x100"), expires_at: 2.hours.from_now.beginning_of_hour) %>

Detail

Add expires_at option to ActiveStorage::Blob#signed_id and URL helpers.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@aki77 aki77 force-pushed the add_expired_at branch 2 times, most recently from 1673efb to 6d1c698 Compare May 2, 2023 22:40
@zzak zzak added this to the 7.1.0 milestone Sep 23, 2023
@rafaelfranca rafaelfranca merged commit 2e93162 into rails:main Sep 26, 2023
4 checks passed
@aki77
Copy link
Contributor Author

aki77 commented Sep 26, 2023

Thanks!

@aki77 aki77 deleted the add_expired_at branch September 26, 2023 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants