app/models/attachment.rb
# Returns a protected access URL.
# Always use this URL to access the attachment.
#
# The 'raw' URL should not be used directly, as there is no guarantee it'll
# work (depending on backing store security settings).
#
# @param expires_in [ActiveSupport::Duration] The duration for which the URL
#   should be valid
#
# @return [String]
Returns a protected access URL.
Always use this URL to access the attachment.

The 'raw' URL should not be used directly, as there is no guarantee it'll
work (depending on backing store security settings).
Returns a protected access URL . Always use this URL to access the attachment . The ' raw ' URL should not be used directly as there is no guarantee it ' ll work ( depending on backing store security settings ) .
def access_url (expires_in = 24.hours)
    now = Time.current
    if self[:access_url] && !access_expired?(now)
      self[:access_url]
    else
      new_access_expires_at = now + expires_in
      new_access_url =
          case backing_store
            when :own_aws_s3
              AwsUtils.cf_signed_url(url, new_access_expires_at + expires_in)
            else
              url
          end
      update_columns access_url: new_access_url,
                     access_expires_at: new_access_expires_at
      new_access_url
    end
  end
def access_url ( expires_in = 24 . hours ) now = Time . current if self [ :access_url ] && ! access_expired? ( now ) self [ :access_url ] else new_access_expires_at = now + expires_in new_access_url = case backing_store when :own_aws_s3 AwsUtils . cf_signed_url ( url , new_access_expires_at + expires_in ) else url end update_columns access_url : new_access_url , access_expires_at : new_access_expires_at new_access_url end end
Returns a protected access URL.
Returns a protected access URL .
# Add more conditions as and when supported # Sneakily double the validity! # This prevents an access URL from being returned with not enough # time left on it.
None
String
expires_in
The duration for which the URL should be valid
The duration for which the URL should be valid
hours