class Shrine::Plugins::RackResponse::FileBody

  1. lib/shrine/plugins/rack_response.rb
Superclass: Object

Implements the interface of a Rack response body object.

Methods

Public Class

  1. new

Public Instance

  1. close
  2. each
  3. file
  4. method_missing
  5. range
  6. respond_to_missing?

Attributes

file [R]
range [R]

Public Class methods

new(file, range: nil)
[show source]
    # File lib/shrine/plugins/rack_response.rb
125 def initialize(file, range: nil)
126   @file  = file
127   @range = range
128 end

Public Instance methods

close()

Closes the file when response body is closed by the web server.

[show source]
    # File lib/shrine/plugins/rack_response.rb
140 def close
141   file.close
142 end
each(&block)

Streams the uploaded file directly from the storage.

[show source]
    # File lib/shrine/plugins/rack_response.rb
131 def each(&block)
132   if range
133     read_partial_chunks(&block)
134   else
135     read_chunks(&block)
136   end
137 end
method_missing(name, *args, &block)

Rack::Sendfile is activated when response body responds to to_path.

[show source]
    # File lib/shrine/plugins/rack_response.rb
150 def method_missing(name, *args, &block)
151   name == :to_path && path or super
152 end
respond_to_missing?(name, include_private = false)

Rack::Sendfile is activated when response body responds to to_path.

[show source]
    # File lib/shrine/plugins/rack_response.rb
145 def respond_to_missing?(name, include_private = false)
146   name == :to_path && path
147 end