diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2017-07-09 00:23:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-09 00:23:11 +0200 |
commit | 839834ed6fc428f777360e7fda5dfb42676e839a (patch) | |
tree | efe28698e7886dde03681b03dfdc1db9c7d07475 /lib | |
parent | 255b1a149c8be93ede25404c53933bde3acc2dc2 (diff) | |
parent | 03120ecb50016fc210945d0824c11d9308b28372 (diff) | |
download | rails-839834ed6fc428f777360e7fda5dfb42676e839a.tar.gz rails-839834ed6fc428f777360e7fda5dfb42676e839a.tar.bz2 rails-839834ed6fc428f777360e7fda5dfb42676e839a.zip |
Merge pull request #22 from jeremy/disk-filename-url
Disk storage: ensure URLs end with the blob filename
Diffstat (limited to 'lib')
-rw-r--r-- | lib/active_storage/disk_controller.rb | 4 | ||||
-rw-r--r-- | lib/active_storage/engine.rb | 2 | ||||
-rw-r--r-- | lib/active_storage/service/disk_service.rb | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/lib/active_storage/disk_controller.rb b/lib/active_storage/disk_controller.rb index 9d5b52d66f..7149cc17a6 100644 --- a/lib/active_storage/disk_controller.rb +++ b/lib/active_storage/disk_controller.rb @@ -9,8 +9,8 @@ require "active_support/core_ext/object/inclusion" # if you are using the +Disk+ service. # # By default, mounting the Active Storage engine inside your application will -# define a +/rails/blobs/:encoded_key+ route that will reference this controller's -# +show+ action and will be used to serve local files. +# define a +/rails/blobs/:encoded_key/*filename+ route that will reference this +# controller's +show+ action and will be used to serve local files. # # A URL for an attachment can be generated through its +#url+ method, that # will use the aforementioned route. diff --git a/lib/active_storage/engine.rb b/lib/active_storage/engine.rb index 3512be0468..d35d3c16db 100644 --- a/lib/active_storage/engine.rb +++ b/lib/active_storage/engine.rb @@ -11,7 +11,7 @@ module ActiveStorage config.after_initialize do |app| app.routes.prepend do - get "/rails/blobs/:encoded_key" => "active_storage/disk#show", as: :rails_disk_blob + get "/rails/blobs/:encoded_key/*filename" => "active_storage/disk#show", as: :rails_disk_blob end end end diff --git a/lib/active_storage/service/disk_service.rb b/lib/active_storage/service/disk_service.rb index 6164caf86c..5576b3b125 100644 --- a/lib/active_storage/service/disk_service.rb +++ b/lib/active_storage/service/disk_service.rb @@ -43,9 +43,9 @@ class ActiveStorage::Service::DiskService < ActiveStorage::Service verified_key_with_expiration = ActiveStorage::VerifiedKeyWithExpiration.encode(key, expires_in: expires_in) if defined?(Rails) && defined?(Rails.application) - Rails.application.routes.url_helpers.rails_disk_blob_path(verified_key_with_expiration, disposition: disposition) + Rails.application.routes.url_helpers.rails_disk_blob_path(verified_key_with_expiration, disposition: disposition, filename: filename) else - "/rails/blobs/#{verified_key_with_expiration}?disposition=#{disposition}" + "/rails/blobs/#{verified_key_with_expiration}/#{filename}?disposition=#{disposition}" end end |