Sha256: 51499128df3a2fef72fe7f6d264ed9aa5a293fd9d7a6fe8fac448161054a2b51

Contents?: true

Size: 1.01 KB

Versions: 46

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

# Proxy files through application. This avoids having a redirect and makes files easier to cache.
#
# WARNING: All Active Storage controllers are publicly accessible by default. The
# generated URLs are hard to guess, but permanent by design. If your files
# require a higher level of protection consider implementing
# {Authenticated Controllers}[https://guides.rubyonrails.org/active_storage_overview.html#authenticated-controllers].
class ActiveStorage::Blobs::ProxyController < ActiveStorage::BaseController
  include ActiveStorage::SetBlob
  include ActiveStorage::Streaming
  include ActiveStorage::DisableSession

  def show
    if request.headers["Range"].present?
      send_blob_byte_range_data @blob, request.headers["Range"]
    else
      http_cache_forever public: true do
        response.headers["Accept-Ranges"] = "bytes"
        response.headers["Content-Length"] = @blob.byte_size.to_s

        send_blob_stream @blob, disposition: params[:disposition]
      end
    end
  end
end

Version data entries

46 entries across 45 versions & 6 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/activestorage-7.0.8.7/app/controllers/active_storage/blobs/proxy_controller.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/activestorage-7.1.3.4/app/controllers/active_storage/blobs/proxy_controller.rb
activestorage-8.0.1 app/controllers/active_storage/blobs/proxy_controller.rb
activestorage-8.0.0.1 app/controllers/active_storage/blobs/proxy_controller.rb
activestorage-7.2.2.1 app/controllers/active_storage/blobs/proxy_controller.rb
activestorage-7.1.5.1 app/controllers/active_storage/blobs/proxy_controller.rb
activestorage-7.0.8.7 app/controllers/active_storage/blobs/proxy_controller.rb
activestorage-8.0.0 app/controllers/active_storage/blobs/proxy_controller.rb
activestorage-7.2.2 app/controllers/active_storage/blobs/proxy_controller.rb
activestorage-7.1.5 app/controllers/active_storage/blobs/proxy_controller.rb
activestorage-8.0.0.rc2 app/controllers/active_storage/blobs/proxy_controller.rb
activestorage-7.2.1.2 app/controllers/active_storage/blobs/proxy_controller.rb
activestorage-7.1.4.2 app/controllers/active_storage/blobs/proxy_controller.rb
activestorage-7.0.8.6 app/controllers/active_storage/blobs/proxy_controller.rb
activestorage-8.0.0.rc1 app/controllers/active_storage/blobs/proxy_controller.rb
activestorage-7.2.1.1 app/controllers/active_storage/blobs/proxy_controller.rb
activestorage-7.1.4.1 app/controllers/active_storage/blobs/proxy_controller.rb
activestorage-7.0.8.5 app/controllers/active_storage/blobs/proxy_controller.rb
activestorage-8.0.0.beta1 app/controllers/active_storage/blobs/proxy_controller.rb
omg-activestorage-8.0.0.alpha9 app/controllers/active_storage/blobs/proxy_controller.rb