Class: OCI::ObjectStorage::Transfer::Multipart::Internal::FilePartIOWrapper
- Inherits:
-
Object
- Object
- OCI::ObjectStorage::Transfer::Multipart::Internal::FilePartIOWrapper
- Defined in:
- lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb
Overview
An IO-like interface over a part of a file which will participate in a multipart upload. This allows us to upload a given segment of the file as an “upload part” of a multipart upload.
Instance Attribute Summary collapse
-
#first_byte ⇒ Integer
readonly
The position of the first byte to start reading from.
-
#last_byte ⇒ Integer
readonly
The position of the last byte we'll read to (exclusive).
-
#offset ⇒ Integer
readonly
The zero-based position in the file to start reading from.
-
#part_size ⇒ Integer
readonly
The number of bytes to read from the file.
-
#source ⇒ String, ...
readonly
The source file, identified by either a File/Tempfile object or a path to the file.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(source:, offset:, part_size:) ⇒ FilePartIOWrapper
constructor
Creates a new FilePartIOWrapper.
- #read(bytes = nil, output_buffer = nil) ⇒ Object
- #rewind ⇒ Object
- #size ⇒ Object
- #write(_content) ⇒ Object
Constructor Details
#initialize(source:, offset:, part_size:) ⇒ FilePartIOWrapper
Creates a new FilePartIOWrapper
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 37 def initialize(source:, offset:, part_size:) @source = source @offset = offset @part_size = part_size @first_byte = offset @last_byte = offset + part_size @file_handle = nil end |
Instance Attribute Details
#first_byte ⇒ Integer (readonly)
The position of the first byte to start reading from. Synonym for offset
26 27 28 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 26 def first_byte @first_byte end |
#last_byte ⇒ Integer (readonly)
The position of the last byte we'll read to (exclusive). Calculated as offset + part_size
30 31 32 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 30 def last_byte @last_byte end |
#offset ⇒ Integer (readonly)
The zero-based position in the file to start reading from
18 19 20 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 18 def offset @offset end |
#part_size ⇒ Integer (readonly)
The number of bytes to read from the file
22 23 24 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 22 def part_size @part_size end |
#source ⇒ String, ... (readonly)
The source file, identified by either a File/Tempfile object or a path to the file
14 15 16 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 14 def source @source end |
Instance Method Details
#close ⇒ Object
48 49 50 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 48 def close @file_handle.close if @file_handle end |
#read(bytes = nil, output_buffer = nil) ⇒ Object
52 53 54 55 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 52 def read(bytes = nil, output_buffer = nil) open_file unless @file_handle read_internal(bytes, output_buffer) end |
#rewind ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 65 def rewind if @file_handle @file_handle.seek(@first_byte) @position = @first_byte end 0 end |
#size ⇒ Object
61 62 63 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 61 def size @part_size end |
#write(_content) ⇒ Object
57 58 59 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 57 def write(_content) raise 'FilePartIOWrapper does not support writing' end |