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.



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

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)


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

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.



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

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.



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

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.



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

def rewind
  @encrypted.rewind
end