Class: Fog::Storage::AWS::Real::S3Streamer
- Inherits:
-
Object
- Object
- Fog::Storage::AWS::Real::S3Streamer
- Defined in:
- lib/fog/aws/storage.rb
Overview
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#date ⇒ Object
Returns the value of attribute date.
-
#finished ⇒ Object
Returns the value of attribute finished.
-
#signature ⇒ Object
Returns the value of attribute signature.
-
#signer ⇒ Object
Returns the value of attribute signer.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(body, signature, signer, date) ⇒ S3Streamer
constructor
A new instance of S3Streamer.
- #next_chunk ⇒ Object
- #sign_chunk(data, previous_signature) ⇒ Object
Constructor Details
#initialize(body, signature, signer, date) ⇒ S3Streamer
Returns a new instance of S3Streamer.
533 534 535 536 537 538 539 540 541 542 543 544 |
# File 'lib/fog/aws/storage.rb', line 533 def initialize(body, signature, signer, date) self.body = body self.date = date self.signature = signature self.signer = signer if body.respond_to?(:binmode) body.binmode end if body.respond_to?(:pos=) body.pos = 0 end end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
532 533 534 |
# File 'lib/fog/aws/storage.rb', line 532 def body @body end |
#date ⇒ Object
Returns the value of attribute date.
532 533 534 |
# File 'lib/fog/aws/storage.rb', line 532 def date @date end |
#finished ⇒ Object
Returns the value of attribute finished.
532 533 534 |
# File 'lib/fog/aws/storage.rb', line 532 def finished @finished end |
#signature ⇒ Object
Returns the value of attribute signature.
532 533 534 |
# File 'lib/fog/aws/storage.rb', line 532 def signature @signature end |
#signer ⇒ Object
Returns the value of attribute signer.
532 533 534 |
# File 'lib/fog/aws/storage.rb', line 532 def signer @signer end |
Instance Method Details
#call ⇒ Object
546 547 548 549 550 551 552 |
# File 'lib/fog/aws/storage.rb', line 546 def call if finished '' else next_chunk end end |
#next_chunk ⇒ Object
554 555 556 557 558 559 560 561 562 |
# File 'lib/fog/aws/storage.rb', line 554 def next_chunk data = body.read(0x10000) if data.nil? self.finished = true data = '' end self.signature = sign_chunk(data, signature) "#{data.length.to_s(16)};chunk-signature=#{signature}\r\n#{data}\r\n" end |
#sign_chunk(data, previous_signature) ⇒ Object
565 566 567 568 569 570 571 572 573 574 575 576 |
# File 'lib/fog/aws/storage.rb', line 565 def sign_chunk(data, previous_signature) string_to_sign = <<-DATA AWS4-HMAC-SHA256-PAYLOAD #{date.to_iso8601_basic} #{signer.credential_scope(date)} #{previous_signature} #{Digest::SHA256.hexdigest('')} #{Digest::SHA256.hexdigest(data)} DATA hmac = signer.derived_hmac(date) hmac.sign(string_to_sign.strip).unpack('H*').first end |