mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Make S3 presigned GET URL expiry configurable (#16912)
Previously we hardcoded the DOWNLOAD_URL_EXPIRES_AFTER_SECONDS const inside S3Helper to be 5 minutes (300 seconds). For various reasons, some hosted sites may need this to be longer for other integrations. The maximum expiry time for presigned URLs is 1 week (which is 604800 seconds), so that has been added as a validation on the setting as well. The setting is hidden because 99% of the time it should not be changed.
This commit is contained in:
@@ -160,7 +160,7 @@ class UploadsController < ApplicationController
|
||||
end
|
||||
|
||||
# defaults to public: false, so only cached by the client browser
|
||||
cache_seconds = S3Helper::DOWNLOAD_URL_EXPIRES_AFTER_SECONDS - SECURE_REDIRECT_GRACE_SECONDS
|
||||
cache_seconds = SiteSetting.s3_presigned_get_url_expires_after_seconds - SECURE_REDIRECT_GRACE_SECONDS
|
||||
expires_in cache_seconds.seconds
|
||||
|
||||
# url_for figures out the full URL, handling multisite DBs,
|
||||
@@ -171,7 +171,7 @@ class UploadsController < ApplicationController
|
||||
|
||||
redirect_to Discourse.store.signed_url_for_path(
|
||||
path_with_ext,
|
||||
expires_in: S3Helper::DOWNLOAD_URL_EXPIRES_AFTER_SECONDS,
|
||||
expires_in: SiteSetting.s3_presigned_get_url_expires_after_seconds,
|
||||
force_download: force_download?
|
||||
), allow_other_host: true
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user