Class: Aws::S3::FilePart Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-s3/file_part.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.

A utility class that provides an IO-like interface to a portion of a file on disk.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ FilePart

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 FilePart.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :source (required, String, Pathname, File, Tempfile)

    The file to upload.

  • :offset (required, Integer)

    The file part will read starting at this byte offset.

  • :size (required, Integer)

    The maximum number of bytes to read from the ‘:offset`.



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

def initialize(options = {})
  @source = options[:source]
  @first_byte = options[:offset]
  @last_byte = @first_byte + options[:size]
  @size = options[:size]
  @file = nil
end

Instance Attribute Details

#first_byteInteger (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)


31
32
33
# File 'lib/aws-sdk-s3/file_part.rb', line 31

def first_byte
  @first_byte
end

#last_byteInteger (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)


34
35
36
# File 'lib/aws-sdk-s3/file_part.rb', line 34

def last_byte
  @last_byte
end

#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)


37
38
39
# File 'lib/aws-sdk-s3/file_part.rb', line 37

def size
  @size
end

#sourceString, ... (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:

  • (String, Pathname, File, Tempfile)


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

def source
  @source
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.



52
53
54
# File 'lib/aws-sdk-s3/file_part.rb', line 52

def close
  @file.close if @file
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.



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

def read(bytes = nil, output_buffer = nil)
  open_file unless @file
  read_from_file(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.



44
45
46
47
48
49
50
# File 'lib/aws-sdk-s3/file_part.rb', line 44

def rewind
  if @file
    @file.seek(@first_byte)
    @position = @first_byte
  end
  0
end