Class: Aws::S3::Encryption::IOEncrypter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-s3/encryption/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 encrpyting a stream of data. It is possible to use this same object for decrypting. You must initialize it with a decryptiion cipher in that case and the IO object must contain cipher text instead of plain text.

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.



20
21
22
23
24
25
# File 'lib/aws-sdk-s3/encryption/io_encrypter.rb', line 20

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)


28
29
30
# File 'lib/aws-sdk-s3/encryption/io_encrypter.rb', line 28

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.



43
44
45
# File 'lib/aws-sdk-s3/encryption/io_encrypter.rb', line 43

def close
  @encrypted.close if Tempfile === @encrypted
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.



30
31
32
33
34
35
36
# File 'lib/aws-sdk-s3/encryption/io_encrypter.rb', line 30

def read(bytes =  nil, output_buffer = nil)
  if Tempfile === @encrypted && @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.



38
39
40
# File 'lib/aws-sdk-s3/encryption/io_encrypter.rb', line 38

def rewind
  @encrypted.rewind
end