aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/app/controllers/active_storage
diff options
context:
space:
mode:
Diffstat (limited to 'activestorage/app/controllers/active_storage')
-rw-r--r--activestorage/app/controllers/active_storage/blobs_controller.rb15
-rw-r--r--activestorage/app/controllers/active_storage/disk_controller.rb6
-rw-r--r--activestorage/app/controllers/active_storage/previews_controller.rb12
-rw-r--r--activestorage/app/controllers/active_storage/variants_controller.rb19
4 files changed, 19 insertions, 33 deletions
diff --git a/activestorage/app/controllers/active_storage/blobs_controller.rb b/activestorage/app/controllers/active_storage/blobs_controller.rb
index 00aa8567c8..a17e3852f9 100644
--- a/activestorage/app/controllers/active_storage/blobs_controller.rb
+++ b/activestorage/app/controllers/active_storage/blobs_controller.rb
@@ -6,20 +6,11 @@
# authenticated redirection controller.
class ActiveStorage::BlobsController < ActionController::Base
def show
- if blob = find_signed_blob
- expires_in 5.minutes # service_url defaults to 5 minutes
- redirect_to blob.service_url(disposition: disposition_param)
+ if blob = ActiveStorage::Blob.find_signed(params[:signed_id])
+ expires_in ActiveStorage::Blob.service.url_expires_in
+ redirect_to blob.service_url(disposition: params[:disposition])
else
head :not_found
end
end
-
- private
- def find_signed_blob
- ActiveStorage::Blob.find_signed(params[:signed_id])
- end
-
- def disposition_param
- params[:disposition].presence_in(%w( inline attachment )) || "inline"
- end
end
diff --git a/activestorage/app/controllers/active_storage/disk_controller.rb b/activestorage/app/controllers/active_storage/disk_controller.rb
index 41e6d61bff..a4fd427cb2 100644
--- a/activestorage/app/controllers/active_storage/disk_controller.rb
+++ b/activestorage/app/controllers/active_storage/disk_controller.rb
@@ -8,7 +8,7 @@ class ActiveStorage::DiskController < ActionController::Base
def show
if key = decode_verified_key
send_data disk_service.download(key),
- disposition: disposition_param, content_type: params[:content_type]
+ disposition: params[:disposition], content_type: params[:content_type]
else
head :not_found
end
@@ -38,10 +38,6 @@ class ActiveStorage::DiskController < ActionController::Base
ActiveStorage.verifier.verified(params[:encoded_key], purpose: :blob_key)
end
- def disposition_param
- params[:disposition].presence || "inline"
- end
-
def decode_verified_token
ActiveStorage.verifier.verified(params[:encoded_token], purpose: :blob_token)
diff --git a/activestorage/app/controllers/active_storage/previews_controller.rb b/activestorage/app/controllers/active_storage/previews_controller.rb
new file mode 100644
index 0000000000..9e8cf27b6e
--- /dev/null
+++ b/activestorage/app/controllers/active_storage/previews_controller.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class ActiveStorage::PreviewsController < ActionController::Base
+ def show
+ if blob = ActiveStorage::Blob.find_signed(params[:signed_blob_id])
+ expires_in ActiveStorage::Blob.service.url_expires_in
+ redirect_to ActiveStorage::Preview.new(blob, params[:variation_key]).processed.service_url(disposition: params[:disposition])
+ else
+ head :not_found
+ end
+ end
+end
diff --git a/activestorage/app/controllers/active_storage/variants_controller.rb b/activestorage/app/controllers/active_storage/variants_controller.rb
index 02e3010626..dc5e78ecc0 100644
--- a/activestorage/app/controllers/active_storage/variants_controller.rb
+++ b/activestorage/app/controllers/active_storage/variants_controller.rb
@@ -6,24 +6,11 @@
# authenticated redirection controller.
class ActiveStorage::VariantsController < ActionController::Base
def show
- if blob = find_signed_blob
- expires_in 5.minutes # service_url defaults to 5 minutes
- redirect_to ActiveStorage::Variant.new(blob, decoded_variation).processed.service_url(disposition: disposition_param)
+ if blob = ActiveStorage::Blob.find_signed(params[:signed_blob_id])
+ expires_in ActiveStorage::Blob.service.url_expires_in
+ redirect_to ActiveStorage::Variant.new(blob, params[:variation_key]).processed.service_url(disposition: params[:disposition])
else
head :not_found
end
end
-
- private
- def find_signed_blob
- ActiveStorage::Blob.find_signed(params[:signed_blob_id])
- end
-
- def decoded_variation
- ActiveStorage::Variation.decode(params[:variation_key])
- end
-
- def disposition_param
- params[:disposition].presence_in(%w( inline attachment )) || "inline"
- end
end