diff options
Diffstat (limited to 'lib/active_file/disk_controller.rb')
-rw-r--r-- | lib/active_file/disk_controller.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/active_file/disk_controller.rb b/lib/active_file/disk_controller.rb index 5140c91f0a..d778cf066f 100644 --- a/lib/active_file/disk_controller.rb +++ b/lib/active_file/disk_controller.rb @@ -1,8 +1,17 @@ +require "action_controller" +require "active_file/blob" +require "active_file/verified_key_with_expiration" + +require "active_support/core_ext/object/inclusion" + class ActiveFile::DiskController < ActionController::Base def show if key = decode_verified_key blob = ActiveFile::Blob.find_by!(key: key) - send_data blob.download, filename: blob.filename, type: blob.content_type, disposition: disposition_param + + if stale?(etag: blob.checksum) + send_data blob.download, filename: blob.filename, type: blob.content_type, disposition: disposition_param + end else head :not_found end @@ -10,7 +19,7 @@ class ActiveFile::DiskController < ActionController::Base private def decode_verified_key - ActiveFile::Site::DiskSite::VerifiedKeyWithExpiration.decode(params[:encoded_key]) + ActiveFile::VerifiedKeyWithExpiration.decode(params[:encoded_key]) end def disposition_param |