Class: Shrine::Plugins::DownloadEndpoint::App
- Inherits:
-
Object
- Object
- Shrine::Plugins::DownloadEndpoint::App
- Defined in:
- lib/shrine/plugins/download_endpoint.rb
Overview
Routes incoming requests. It first asserts that the storage is existent and allowed. Afterwards it proceeds with the file download using streaming.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(options) ⇒ App
constructor
Writes given options to instance variables.
- #inspect ⇒ Object (also: #to_s)
Constructor Details
#initialize(options) ⇒ App
Writes given options to instance variables.
114 115 116 117 118 |
# File 'lib/shrine/plugins/download_endpoint.rb', line 114 def initialize() .each do |name, value| instance_variable_set("@#{name}", value) end end |
Instance Method Details
#call(env) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/shrine/plugins/download_endpoint.rb', line 120 def call(env) request = Rack::Request.new(env) status, headers, body = catch(:halt) do error!(405, "Method Not Allowed") unless request.get? handle_request(request) end headers["Content-Length"] ||= body.map(&:bytesize).inject(0, :+).to_s [status, headers, body] end |
#inspect ⇒ Object Also known as: to_s
134 135 136 |
# File 'lib/shrine/plugins/download_endpoint.rb', line 134 def inspect "#<#{@shrine_class}::DownloadEndpoint>" end |