Class: Aws::S3::EncryptionV2::IOEncrypter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-s3/encryptionV2/io_encrypter.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Provides an IO wrapper encrypting a stream of data.

Constant Summary collapse

ONE_MEGABYTE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

1024 * 1024

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cipher, io) ⇒ IOEncrypter

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of IOEncrypter.



17
18
19
20
21
22
# File 'lib/aws-sdk-s3/encryptionV2/io_encrypter.rb', line 17

def initialize(cipher, io)
  @encrypted = io.size <= ONE_MEGABYTE ?
    encrypt_to_stringio(cipher, io.read) :
    encrypt_to_tempfile(cipher, io)
  @size = @encrypted.size
end

Instance Attribute Details

#sizeInteger (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Integer)


25
26
27
# File 'lib/aws-sdk-s3/encryptionV2/io_encrypter.rb', line 25

def size
  @size
end

Instance Method Details

#closeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



40
41
42
# File 'lib/aws-sdk-s3/encryptionV2/io_encrypter.rb', line 40

def close
  @encrypted.close if @encrypted.is_a?(Tempfile)
end

#read(bytes = nil, output_buffer = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



27
28
29
30
31
32
33
# File 'lib/aws-sdk-s3/encryptionV2/io_encrypter.rb', line 27

def read(bytes = nil, output_buffer = nil)
  if @encrypted.is_a?(Tempfile) && @encrypted.closed?
    @encrypted.open
    @encrypted.binmode
  end
  @encrypted.read(bytes, output_buffer)
end

#rewindObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



35
36
37
# File 'lib/aws-sdk-s3/encryptionV2/io_encrypter.rb', line 35

def rewind
  @encrypted.rewind
end