Class: Upstream
- Inherits:
-
Object
- Object
- Upstream
- Defined in:
- lib/s3_streamer/client/upstream.rb
Instance Method Summary collapse
- #complete ⇒ Object
-
#initialize(client, bucket, destination_file) ⇒ Upstream
constructor
A new instance of Upstream.
- #upload(chunk) ⇒ Object
Constructor Details
#initialize(client, bucket, destination_file) ⇒ Upstream
Returns a new instance of Upstream.
2 3 4 5 6 7 8 9 |
# File 'lib/s3_streamer/client/upstream.rb', line 2 def initialize(client, bucket, destination_file) @client = client @bucket = bucket @destination_file = destination_file @parts = [] @part_number = 1 @upload_id = create end |
Instance Method Details
#complete ⇒ Object
23 24 25 26 27 28 |
# File 'lib/s3_streamer/client/upstream.rb', line 23 def complete @client.complete_multipart_upload(bucket: @bucket, key: @destination_file, upload_id: @upload_id, multipart_upload: {parts: @parts}) end |
#upload(chunk) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/s3_streamer/client/upstream.rb', line 11 def upload(chunk) uploaded_part = @client.upload_part(body: chunk, bucket: @bucket, key: @destination_file, part_number: @part_number, upload_id: @upload_id) @parts << {etag: uploaded_part.etag, part_number: @part_number} @part_number += 1 end |