Class: S3Streamer::Streamer

Inherits:
Object
  • Object
show all
Defined in:
lib/s3streamer/streamer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, bucket = nil) ⇒ Streamer

Creates a Stremer object by fetching object the to be stremed and storing it for further processing

Parameters:

  • key (String)

    The path to the object in the bucket

  • bucket (String) (defaults to: nil)

    The bucket name to use. Can be omitted to use the default configured bucket


11
12
13
14
15
16
# File 'lib/s3streamer/streamer.rb', line 11

def initialize key, bucket = nil
  # Use default bucket if not set
  bucket ||= S3Streamer.bucket
  # Fetch object to be streamed
  @object = AWS::S3::Bucket.new(bucket).objects[key]
end

Instance Attribute Details

#objectObject

Returns the value of attribute object.


3
4
5
# File 'lib/s3streamer/streamer.rb', line 3

def object
  @object
end

Instance Method Details

#eachObject

Method to be called by Rack to stream our stored object


20
21
22
23
24
# File 'lib/s3streamer/streamer.rb', line 20

def each
  @object.read do |segment|
    yield segment
  end
end