class Shrine::Plugins::RackResponse::FileBody
Implements the interface of a Rack response body object.
Attributes
Public Class Methods
Source
# File lib/shrine/plugins/rack_response.rb 127 def initialize(file, range: nil) 128 @file = file 129 @range = range 130 end
Public Instance Methods
Source
# File lib/shrine/plugins/rack_response.rb 146 def bytesize 147 each.inject(0) { |sum, chunk| sum += chunk.length } 148 end
Source
# File lib/shrine/plugins/rack_response.rb 142 def close 143 file.close 144 end
Closes the file when response body is closed by the web server.
Source
# File lib/shrine/plugins/rack_response.rb 133 def each(&block) 134 if range 135 read_partial_chunks(&block) 136 else 137 read_chunks(&block) 138 end 139 end
Streams the uploaded file directly from the storage.
# File lib/shrine/plugins/rack_response.rb 156 def method_missing(name, *args, &block) 157 name == :to_path && path or super 158 end
Rack::Sendfile is activated when response body responds to #to_path.
Calls superclass method
# File lib/shrine/plugins/rack_response.rb 151 def respond_to_missing?(name, include_private = false) 152 name == :to_path && path 153 end
Rack::Sendfile is activated when response body responds to #to_path.