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
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 36 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
25 26 27 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 25 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
29 30 31 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 29 def last_byte @last_byte end |
#offset ⇒ Integer (readonly)
The zero-based position in the file to start reading from
17 18 19 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 17 def offset @offset end |
#part_size ⇒ Integer (readonly)
The number of bytes to read from the file
21 22 23 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 21 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
13 14 15 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 13 def source @source end |
Instance Method Details
#close ⇒ Object
47 48 49 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 47 def close @file_handle.close if @file_handle end |
#read(bytes = nil, output_buffer = nil) ⇒ Object
51 52 53 54 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 51 def read(bytes = nil, output_buffer = nil) open_file unless @file_handle read_internal(bytes, output_buffer) end |
#rewind ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 64 def rewind if @file_handle @file_handle.seek(@first_byte) @position = @first_byte end 0 end |
#size ⇒ Object
60 61 62 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 60 def size @part_size end |
#write(_content) ⇒ Object
56 57 58 |
# File 'lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb', line 56 def write(_content) raise 'FilePartIOWrapper does not support writing' end |