Class: PostgresqlLoStreamer::LoController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/postgresql_lo_streamer/lo_controller.rb

Instance Method Summary collapse

Instance Method Details

#connectionObject



22
23
24
# File 'app/controllers/postgresql_lo_streamer/lo_controller.rb', line 22

def connection
  @con ||= ActiveRecord::Base.connection.raw_connection
end

#streamObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/postgresql_lo_streamer/lo_controller.rb', line 6

def stream

  streamer = PostgresqlLoStreamer::Streamer.new(
    connection,
    params[:id].to_i
  )
  send_file_headers!(default_headers_for(params[:format]))
  if !streamer.object_exists?
    head 404, default_headers_for(params[:format])
    return
  end
  self.status = 200
  self.response_body = streamer.stream

end