From d8bf5d73c39ff6758b3a86a58b1b096006f4bb42 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 15 Aug 2017 21:57:27 +0200 Subject: restores some double newlines deleted in ae87217 These were intentional, see https://github.com/rails/rails/pull/30061#issuecomment-320068368 --- activestorage/app/controllers/active_storage/disk_controller.rb | 2 ++ activestorage/app/models/active_storage/blob.rb | 3 +++ activestorage/app/models/active_storage/variant.rb | 1 + 3 files changed, 6 insertions(+) (limited to 'activestorage/app') diff --git a/activestorage/app/controllers/active_storage/disk_controller.rb b/activestorage/app/controllers/active_storage/disk_controller.rb index dee88054da..b10d4e2cac 100644 --- a/activestorage/app/controllers/active_storage/disk_controller.rb +++ b/activestorage/app/controllers/active_storage/disk_controller.rb @@ -33,6 +33,7 @@ class ActiveStorage::DiskController < ActionController::Base ActiveStorage::Blob.service end + def decode_verified_key ActiveStorage.verifier.verified(params[:encoded_key], purpose: :blob_key) end @@ -41,6 +42,7 @@ class ActiveStorage::DiskController < ActionController::Base params[:disposition].presence_in(%w( inline attachment )) || "inline" end + def decode_verified_token ActiveStorage.verifier.verified(params[:encoded_token], purpose: :blob_token) end diff --git a/activestorage/app/models/active_storage/blob.rb b/activestorage/app/models/active_storage/blob.rb index 36b8a35778..9f2ed1e5ac 100644 --- a/activestorage/app/models/active_storage/blob.rb +++ b/activestorage/app/models/active_storage/blob.rb @@ -59,6 +59,7 @@ class ActiveStorage::Blob < ActiveRecord::Base end end + # Returns a signed ID for this blob that's suitable for reference on the client-side without fear of tampering. # It uses the framework-wide verifier on ActiveStorage.verifier, but with a dedicated purpose. def signed_id @@ -120,6 +121,7 @@ class ActiveStorage::Blob < ActiveRecord::Base ActiveStorage::Variant.new(self, ActiveStorage::Variation.new(transformations)) end + # Returns the URL of the blob on the service. This URL is intended to be short-lived for security and not used directly # with users. Instead, the +service_url+ should only be exposed as a redirect from a stable, possibly authenticated URL. # Hiding the +service_url+ behind a redirect also gives you the power to change services without updating all URLs. And @@ -162,6 +164,7 @@ class ActiveStorage::Blob < ActiveRecord::Base service.download key, &block end + # Deletes the file on the service that's associated with this blob. This should only be done if the blob is going to be # deleted as well or you will essentially have a dead reference. It's recommended to use the +#purge+ and +#purge_later+ # methods in most circumstances. diff --git a/activestorage/app/models/active_storage/variant.rb b/activestorage/app/models/active_storage/variant.rb index 92fa445095..40648a27f7 100644 --- a/activestorage/app/models/active_storage/variant.rb +++ b/activestorage/app/models/active_storage/variant.rb @@ -65,6 +65,7 @@ class ActiveStorage::Variant service.url key, expires_in: expires_in, disposition: disposition, filename: blob.filename, content_type: blob.content_type end + private def processed? service.exist?(key) -- cgit v1.2.3