Class: Fog::AWS::Storage::Real::S3Streamer
- Inherits:
-
Object
- Object
- Fog::AWS::Storage::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.
-
#initial_signature ⇒ Object
Returns the value of attribute initial_signature.
-
#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
-
#rewind ⇒ Object
called if excon wants to retry the request.
- #sign_chunk(data, previous_signature) ⇒ Object
Constructor Details
#initialize(body, signature, signer, date) ⇒ S3Streamer
Returns a new instance of S3Streamer.
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 |
# File 'lib/fog/aws/storage.rb', line 663 def initialize(body, signature, signer, date) self.body = body self.date = date self.signature = signature self.initial_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.
662 663 664 |
# File 'lib/fog/aws/storage.rb', line 662 def body @body end |
#date ⇒ Object
Returns the value of attribute date.
662 663 664 |
# File 'lib/fog/aws/storage.rb', line 662 def date @date end |
#finished ⇒ Object
Returns the value of attribute finished.
662 663 664 |
# File 'lib/fog/aws/storage.rb', line 662 def finished @finished end |
#initial_signature ⇒ Object
Returns the value of attribute initial_signature.
662 663 664 |
# File 'lib/fog/aws/storage.rb', line 662 def initial_signature @initial_signature end |
#signature ⇒ Object
Returns the value of attribute signature.
662 663 664 |
# File 'lib/fog/aws/storage.rb', line 662 def signature @signature end |
#signer ⇒ Object
Returns the value of attribute signer.
662 663 664 |
# File 'lib/fog/aws/storage.rb', line 662 def signer @signer end |
Instance Method Details
#call ⇒ Object
687 688 689 690 691 692 693 |
# File 'lib/fog/aws/storage.rb', line 687 def call if finished '' else next_chunk end end |
#next_chunk ⇒ Object
695 696 697 698 699 700 701 702 703 |
# File 'lib/fog/aws/storage.rb', line 695 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 |
#rewind ⇒ Object
called if excon wants to retry the request. As well as rewinding the body we must also reset the signature
681 682 683 684 685 |
# File 'lib/fog/aws/storage.rb', line 681 def rewind self.signature = initial_signature self.finished = false body.rewind end |
#sign_chunk(data, previous_signature) ⇒ Object
706 707 708 709 710 711 712 713 714 715 716 717 |
# File 'lib/fog/aws/storage.rb', line 706 def sign_chunk(data, previous_signature) string_to_sign = <<-DATA AWS4-HMAC-SHA256-PAYLOAD #{date.to_iso8601_basic} #{signer.credential_scope(date)} #{previous_signature} #{OpenSSL::Digest::SHA256.hexdigest('')} #{OpenSSL::Digest::SHA256.hexdigest(data)} DATA hmac = signer.derived_hmac(date) hmac.sign(string_to_sign.strip).unpack('H*').first end |