diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2018-03-03 21:36:43 +0100 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2018-03-03 21:36:43 +0100 |
commit | 0f302b897022b68793e102efa90a2819ff4e107a (patch) | |
tree | 8db635773878ae88556162cc34ecc244c83cb7b8 /activestorage/app/controllers/active_storage | |
parent | 6932998fc7aecba6ade04f8d799f07b494dd402c (diff) | |
download | rails-0f302b897022b68793e102efa90a2819ff4e107a.tar.gz rails-0f302b897022b68793e102efa90a2819ff4e107a.tar.bz2 rails-0f302b897022b68793e102efa90a2819ff4e107a.zip |
Merge Previews/Variants controller into one Representations controller.
Since ActiveStorage::Blob::Representable unifies the idea of previews and
variants under one roof as representation, we may as well have the
controllers follow suit.
Thus ActiveStorage::RepresenationsController enters the fray. I've copied
the old tests for both previews and variants and unified those as well.
Diffstat (limited to 'activestorage/app/controllers/active_storage')
-rw-r--r-- | activestorage/app/controllers/active_storage/previews_controller.rb | 10 | ||||
-rw-r--r-- | activestorage/app/controllers/active_storage/representations_controller.rb (renamed from activestorage/app/controllers/active_storage/variants_controller.rb) | 6 |
2 files changed, 3 insertions, 13 deletions
diff --git a/activestorage/app/controllers/active_storage/previews_controller.rb b/activestorage/app/controllers/active_storage/previews_controller.rb deleted file mode 100644 index aa7ef58ca4..0000000000 --- a/activestorage/app/controllers/active_storage/previews_controller.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class ActiveStorage::PreviewsController < ActionController::Base - include ActiveStorage::SetBlob - - def show - expires_in ActiveStorage::Blob.service.url_expires_in - redirect_to ActiveStorage::Preview.new(@blob, params[:variation_key]).processed.service_url(disposition: params[:disposition]) - end -end diff --git a/activestorage/app/controllers/active_storage/variants_controller.rb b/activestorage/app/controllers/active_storage/representations_controller.rb index e8f8dd592d..e0e944dc9c 100644 --- a/activestorage/app/controllers/active_storage/variants_controller.rb +++ b/activestorage/app/controllers/active_storage/representations_controller.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -# Take a signed permanent reference for a variant and turn it into an expiring service URL for download. +# Take a signed permanent reference for a blob representation and turn it into an expiring service URL for download. # Note: These URLs are publicly accessible. If you need to enforce access protection beyond the # security-through-obscurity factor of the signed blob and variation reference, you'll need to implement your own # authenticated redirection controller. -class ActiveStorage::VariantsController < ActionController::Base +class ActiveStorage::RepresentationsController < ActionController::Base include ActiveStorage::SetBlob def show expires_in ActiveStorage::Blob.service.url_expires_in - redirect_to ActiveStorage::Variant.new(@blob, params[:variation_key]).processed.service_url(disposition: params[:disposition]) + redirect_to @blob.representation(params[:variation_key]).processed.service_url(disposition: params[:disposition]) end end |