From 9e81741b342a1a8a1ace94d356e023031d386689 Mon Sep 17 00:00:00 2001
From: David Heinemeier Hansson <david@loudthinking.com>
Date: Sun, 23 Jul 2017 10:56:53 -0500
Subject: Disk controller must rely on key alone

Otherwise it can't be used to display variants. It's better anyway since all other services won't know about blobs either. Better simulation. Closes #71
---
 app/controllers/active_storage/disk_controller.rb | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

(limited to 'app/controllers')

diff --git a/app/controllers/active_storage/disk_controller.rb b/app/controllers/active_storage/disk_controller.rb
index ae8cbddefa..62380a3774 100644
--- a/app/controllers/active_storage/disk_controller.rb
+++ b/app/controllers/active_storage/disk_controller.rb
@@ -11,17 +11,18 @@
 class ActiveStorage::DiskController < ActionController::Base
   def show
     if key = decode_verified_key
-      blob = ActiveStorage::Blob.find_by!(key: key)
-
-      if stale?(etag: blob.checksum)
-        send_data blob.download, filename: blob.filename, type: blob.content_type, disposition: disposition_param
-      end
+      # FIXME: Find a way to set the correct content type
+      send_data disk_service.download(key), filename: params[:filename], disposition: disposition_param
     else
       head :not_found
     end
   end
 
   private
+    def disk_service
+      ActiveStorage::Blob.service
+    end
+
     def decode_verified_key
       ActiveStorage::VerifiedKeyWithExpiration.decode(params[:encoded_key])
     end
-- 
cgit v1.2.3