Class: S3Streamer::Downstream
- Inherits:
-
Object
- Object
- S3Streamer::Downstream
- Defined in:
- lib/s3_streamer/downstream.rb
Constant Summary collapse
- DEFAULT_PART_SIZE =
10 * 1024 * 1024
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(uri, options = {}) ⇒ Downstream
constructor
A new instance of Downstream.
Constructor Details
#initialize(uri, options = {}) ⇒ Downstream
Returns a new instance of Downstream.
8 9 10 11 |
# File 'lib/s3_streamer/downstream.rb', line 8 def initialize(uri, ={}) @uri = uri = end |
Instance Method Details
#each ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/s3_streamer/downstream.rb', line 13 def each Net::HTTP.start(@uri.host) do |http| http.request(Net::HTTP::Get.new @uri) do |response| buffer = BufferedWriter.new(min_part_size: part_size) do |part| yield part end response.read_body { |chunk| buffer.push chunk } buffer.finish end end end |